begin process at 2012 05 26 16:18:25
  Trouver un code source :
 
dans
 
Accueil > Forum > 

Archive Flash

 > 

Archives

 > 

ActionScript

 > 

Chargement texte dynamique particulier avec flash 8


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

Chargement texte dynamique particulier avec flash 8

samedi 12 novembre 2005 à 18:52:23 | Chargement texte dynamique particulier avec flash 8

A2linegarnoule

Bonjour,

Je ne m'y connais pas assez en AS pour comprendre d'où vient le pb...
Voici le code que je mettais pour charger un texte dynamique (avec couleur, soulignement, etc...) dans flash mx :

#initclip 1

if (LoadTextClass == undefined) {
 LoadTextClass = function () {
  this._visible=false;
  this.init();
 };

 LoadTextClass.prototype = new MovieClip();

 Object.registerClass("LoadText", LoadTextClass);

 LoadTextClass.prototype.init = function() {
  this.defineProperties();
  this.loadedz=false;
  if (this.usecodepage==undefined) this.usecodepage=true;
  if (this.enablehtml==undefined) this.enablehtml=true;
  if (this.enabletracing==undefined) this.enabletracing=true;
  if (this._targetInstanceName!=undefined) {
   this.setTarget(this._targetInstanceName)
   this.originalText = this.targetInstance.text;
   if (this.targetInstance!=undefined) this.loadText(this.textfile,this.targetInstance);
  }
 };

 LoadTextClass.prototype.defineProperties = function() {
  this.addProperty("_text", this.getTextFile, this.setTextFile);
  this.addProperty("_targetField", this.getTarget, this.setTarget);
  this.addProperty("_html", this.getHtml, this.setHtml);
  this.addProperty("_accents", this.getAccents, this.setAccents);
  this.addProperty("_waitingText", this.getWaitingText, this.setWaitingText);
  this.addProperty("_tracing", this.getTracing, this.setTracing);
  this.addProperty("_loaded",this.getLoaded, null);
  this.addProperty("_targetVar",this.getTargetVar, this.setTargetVar);
  this.addProperty("_callback",this.getCallback, this.setCallback);
  this.addProperty("_allowedDomain",this.getAllowedDomain, this.setAllowedDomain);
  this.addProperty("_caching",this.getCaching, this.getCaching);
  this.addProperty("_bytesLoaded",this.getBytesLoaded, null);
  this.addProperty("_bytesTotal",this.getBytesTotal, null);
 }

 LoadTextClass.prototype.getTextFile = function() {
  return this.textfile;
 }
 LoadTextClass.prototype.setTextFile = function(urlz) {
  this.textfile = urlz
  return urlz;
 }
 LoadTextClass.prototype.getTarget = function() {
  return this.targetInstance;
 }
 LoadTextClass.prototype.setTarget = function(tf) {
  this.targetInstance = (this._parent[tf] instanceof TextField) ? this._parent[tf] : eval(tf);
  return tf;
 }
 LoadTextClass.prototype.getHtml = function() {
  return (this.enablehtml==true) ? true : false;
 }
 LoadTextClass.prototype.setHtml = function(bool) {
  this.enablehtml=bool;
  return (this.enablehtml==bool) ? true : false;
 }
 LoadTextClass.prototype.getAccents = function() {
  return (this.usecodepage==true) ? true : false;
 }
 LoadTextClass.prototype.setAccents = function(bool) {
  this.usecodepage=bool;
  return (this.usecodepage==bool) ? true : false;
 }
 LoadTextClass.prototype.getWaitingText = function() {
  return this.waitingtext;
 }
 LoadTextClass.prototype.setWaitingText = function(bla) {
  this.waitingtext=bla;
  return bla;
 }
 LoadTextClass.prototype.getTracing = function() {
  return (this.enabletracing==true) ? true : false;
 }
 LoadTextClass.prototype.setTracing = function(bool) {
  this.enabletracing=bool;
  return (this.enabletracing==bool) ? true : false;
 }
 LoadTextClass.prototype.getLoaded = function() {
  return this.loadedz;
 }
 LoadTextClass.prototype.getTargetVar = function() {
  return this.targetVar;
 }
 LoadTextClass.prototype.setTargetVar = function(targetz) {
  this.targetVar = targetz
  return targetz;
 }
 LoadTextClass.prototype.getCallback = function() {
  return this.callback;
 }
 LoadTextClass.prototype.setCallback = function(callback) {
  this.callback = callback
  return callback;
 }
 LoadTextClass.prototype.getAllowedDomain = function() {
  return this.secdomain;
 }
 LoadTextClass.prototype.setAllowedDomain = function(secdomain) {
  this.secdomain = secdomain;
  return secdomain;
 }
 LoadTextClass.prototype.getCaching = function() {
  return (this.caching==true) ? true : false;
 }
 LoadTextClass.prototype.setCaching = function(bool) {
  this.caching=bool;
  return (this.caching==bool) ? true : false;
 }
 LoadTextClass.prototype.getBytesLoaded = function() {
  if (this.loadTextRaw) return this.loadTextRaw.getBytesLoaded();
  //else return 0;
 }
 LoadTextClass.prototype.getBytesTotal = function() {
  if (this.loadTextRaw) return this.loadTextRaw.getBytesTotal();
  //else return 0;
 }
 String.prototype.LoadTextReplace = function(strng, toReplace) {
  var temparray = this.split(strng);
  return temparray.join(toReplace);
 };

 LoadTextClass.prototype.loadText = function(textfile,targetz) {
  if (textfile != undefined) this.textfile=textfile;
  if (targetz.length>0) {
   this.setTarget(targetz)
  }

  System.useCodepage = (this.usecodepage==true) ? true : false;
  if (System.capabilities.manufacturer=="Macintosh") System.useCodePage=false; // mac bug patch

  if (this.secdomain!=undefined && this.secdomain!="") {
   System.security.allowDomain(this.secdomain);
   if (this.enabletracing) trace ("--- LoadText secured domain: "+this.secdomain);
  }

  if (this.targetInstance != undefined) {
   if (this.targetInstance instanceof TextField) {
    if (this.targetInstance.type == "dynamic" || this.targetInstance.type == "input") {
     this.targetVarTest = eval(this.targetVar);
     if (this.caching == true && (this.targetVarTest != "" && this.targetVarTest != undefined)){
      if (this.enabletracing) trace ("--- LoadText caching   : reading '"+this.targetVar+"' instead of loading");
      if (this.enablehtml==true) {
       this.targetInstance.html = true;
       this.targetInstance.htmlText = this.targetVarTest;
      }else this.targetInstance.text = this.targetVarTest;
      this.onLoad(true);
     }else if (this.caching==false || (this.caching==true && (this.targetVarTest=="" || !this.targetVarTest)) ||
     (this.targetInstance.text.length==0 || this.targetInstance.text==this.waitingtext || this.targetInstance.text==this.originalText)
     ) {
      if (this.enabletracing) trace ("--- LoadText target    : "+this.targetInstance);
      if (this.textfile != undefined && this.textfile != "" && this.textfile != ".txt") {
       if (this.enabletracing) trace ("--- LoadText file      : "+this.textfile);
       if (this.waitingtext!="") this.targetInstance.text=this.waitingtext;
       this.loadTextRaw = new LoadVars();
       this.loadTextRaw.targetz=this.targetInstance;
       this.loadTextRaw.enablehtml=this.enablehtml;
       this.loadTextRaw.enabletracing=this.enabletracing;
       this.loadTextRaw.targetVar=this.targetVar;
       this.loadTextRaw.callback=this.callback;
       this.loadTextRaw.parentObj=this;
       this.loadTextRaw.onData = function(raw){
        this.rawtemp = raw.loadTextReplace("\n","");
        if(this.rawtemp!=""){ //  find/make a real 404 test (get http header)
         if (this.enablehtml==true) {
          this.targetz.html = true;
          this.targetz.htmlText = this.rawtemp;
         }else this.targetz.text = this.rawtemp;
         this.onLoad(true);
        }else this.onLoad(false);
       }
       this.loadTextRaw.onLoad = function(success){
        if(success){
         this.parentObj.loadedz = this.loadedz = true;
         if (this.targetVar!=undefined && this.targetVar!= "") {
          set(this.targetVar,this.rawtemp);
          if (this.enabletracing) {
           if (eval(this.targetVar)!="" && eval(this.targetVar) != undefined) trace ("--- LoadText targetVar : var "+this.targetVar+" created");
           else trace ("--- LoadText targetVar : error ! var "+this.targetVar+" wasn't created");
          }
         }
         if (this.callback!=undefined && this.callback!="") {
          this.callback=this.callback.LoadTextReplace("()","")
          if (typeof(eval(this.callback))=="function") {
           if (this.enabletracing) trace ("--- LoadText callback  : function "+this.callback+"() called");
           eval(this.callback)(true);
          }else if (this.enabletracing) trace ("--- LoadText callback  : '"+this.callback+"' is not a function or the path isn't correct");
         }
        }else if (this.enabletracing) trace ("--- LoadText error     : loading failed");
       }
       this.loadTextRaw.load(this.textfile);
      }else if (this.enabletracing) trace ("--- LoadText error     : no textfile specified");
     }else if (this.enabletracing) trace ("--- LoadText cache     : text already loaded");
    }else if (this.enabletracing) trace ("--- LoadText error     : the target textfield isn't dynamic");
   }else if (this.enabletracing) trace ("--- LoadText error     : the target isn't a textfield");
  }else if (this.enabletracing) trace ("--- LoadText error     : no target textfield specified");
 }
}else if (this.enabletracing) trace ("--- LoadText error     : unable to create the class (already exists)");

#endinitclip

mais dans flash 8, à la place du texte, il écrit "undefined", je ne sais pas où se situe l'erreur...

Merci beaucoup de m'aider !

a2line



Cette discussion est classée dans : function, true, return, prototype, loadtextclass


Répondre à ce message

Sujets en rapport avec ce message

désactiver temporairement la souris [ par djagger ] Salut ! Dans mon animation, je charge une biblio d'icones (jpeg ou swf). Mon problème est le suivant, si je bouge bcp la souris lors du chargement, ca prototype [ par desstrain ] reBonjour :)2eme question pour ce soir, qui tout comme l'autre, me desastre depuis quelques jours... voila j'essaie de faire des mini preloader mais ç Aide DropTarget !!! svp !!! [ par scareface ] oici mon code : stop(); glass.onPress = function() { Mouse.hide(); this.startDrag(true, 10, 10, 740, 340); this.swapDepths(100); }; glass.onRelease = return : utilité ?? [ par Orange73 ] Hello,voilà quelque temps que je me penche sur "return" ...Je souhaiterai simplement connaitre :> Son utilité ?> Savoir dans quels cas on doit l'utili probleme entre 2 movieClipLoader et 1 onEnterFrame [ par Flothi27 ] Mon code permet d'afficher des images avec un effet de fondu mais seulle la première image est jouée.Voici mon code :importmx.transitions.Tween;<font Déplacement voiture, elle veut pas démarrer !! [ par mixomatoz ] Bonjour, Je suis tout nouveau et un gros tacheron en flash (comme ds bien d'autres domaines...).Je cherche a gérer le déplacement d'une voiture vue de bouton+clip [ par cyan59 ] bonjours à tous j' ai reussi à faire un clip qui qd je passe dessus l anim se lance et qd je part de celle ci elle se lance en arriere avec ce code à jquery / Mootools non compatible ? [ par dreadstock ] Bonjour à tous ,Je suis en train de créer un site web pour mon frangin. Je souhaite intégrer 2 bibliothèques jquery et mootools plus particulierement Un "bouton clip" dans un "bouton clip" ?! [ par ximeng ] Bonjour je suis novice en AS, j'utilise l'AS2 pour le moment et j'ai rencontré un problème que je n'arrive vraiment pas a résoudre...Créer une chaine probleme d'action sur les boutons [ par jul13n ] Bonjour, J'ai réalisé un site se basant sur pageflip. Ce site est composé de deux animations, le pageflip et une animation acceuillant les boutons et


Nos sponsors


Sondage...

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

A découvrir



 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,686 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales