2010-09-06 7 views
0

J'essaye de construire un préchargement simple. J'ai 4 MovieClips sur scène et sur chacun d'eux je suis ajout d'une image qui vient d'un fichier xmlAs2 jpg preloader tiré de xml

theMap = new XML(); 
theMap.ignoreWhite = true; 

theMap.onLoad = function(success){ 
    if (success) { 
     theNodes = theMap.firstChild.childNodes; 
     for (i=0;i < theNodes.length;i++) { 
      theSrc  = theNodes[i].attributes.src; //the jpg 
      theClip  = theNodes[i].attributes.clip; //the movieclip 
      _root[theClip].loadMovie(theSrc); // adding the jpg to the movieclip 
     } 
    } 
    else { 
     trace('Cannot Load XML file.'); 
    } 
} 
theMap.load("map.xml"); 

tout fonctionne bien, mais comme les fichiers JPG sont un peu lourd je voudrais les précharger. Est-ce possible?

Répondre

0
 var mcLoader:MovieClipLoader = new MovieClipLoader(); 
     mcLoader.addListener(this); 
     this.onLoadProgress = function(target_mc:MovieClip,bytesLoaded:Number,bytesTotal:Number){ 
      var percentage:Number = int(bytesLoaded/bytesTotal*100); 
      trace(percentage); 
      if (percentage >= 100) { _root.waiting._visible = false; } 
     } 

     mcLoader.loadClip(theSrc,theClip);