Your code will load the same SWF again and again forever.

I wrote a sequential loading script for someone recently, may be you can adopt the concept from it. This script gathers the total byte size of all the SWFs first, then starts loading SWFs one by one, so that you can monitor the loading progress. (You'll probably need to add some error checking mechanism to make it more robust though.)

//
var swfList:Array = ["1.swf", "2.swf", "3.swf", "4.swf", "5.swf"];
var swfBytesList:Array = new Array();
var loadID:Number = 0;
var isTestLoad:Boolean = true;
var grossBytes:Number = 0;
var bytesCompleted:Number = 0;
var myMCL:MovieClipLoader = new MovieClipLoader();
var myListener:Object = new Object();
myMCL.addListener(myListener);
myListener.onLoadProgress = function(target_mc:MovieClip, loadedBytes:Number, totalBytes:Number):Void {
   if (isTestLoad) {
       if (totalBytes) {
           swfBytesList.push(totalBytes);
           trace("SWF: "+target_mc._url);
           trace("totalBytes: "+totalBytes);
           grossBytes += totalBytes;
           trace("grossBytes so far: "+grossBytes);
           trace("***");
           loadID++;
           if (loadID<swfList.length) {
               testLoad(loadID);
           } else {
               trace("Final grossBytes: "+grossBytes);
               trace("***");
               myMCL.unloadClip(mcTemp);
               mcTemp.removeMovieClip();
               trace("Start sequential loading");
               trace("***");
               isTestLoad = false;
               loadID = 0;
               sequentialLoad(loadID);
           }
       }
   } else {
       trace("Currently loading "+target_mc._url);
       var bytesSoFar:Number = bytesCompleted+loadedBytes;
       trace("Bytes loaded so far: "+bytesSoFar);
var percentageLoaded:Number = Math.floor(10000*bytesSoFar/grossBytes)/100;
       trace(percentageLoaded+"%");
       trace("***");
   }
};
myListener.onLoadComplete = function(targetMC:MovieClip, httpStatus:Number):Void {
   if (!isTestLoad) {
       bytesCompleted += swfBytesList[loadID];
       trace("Load completed for "+targetMC._url);
       trace("***");
       loadID++;
       if (loadID>=swfList.length) {
           trace("All loadings completed!");
       } else {
           sequentialLoad(loadID);
       }
   }
};
function sequentialLoad(loadID:Number):Void {
   var ID:Number = loadID+1;
   var mc:MovieClip = this.createEmptyMovieClip("mc"+ID, ID);
   myMCL.loadClip(swfList[loadID], mc);
}
function testLoad(loadID:Number):Void {
   mcTemp.removeMovieClip();
   this.createEmptyMovieClip("mcTemp", 1);
   myMCL.loadClip(swfList[loadID], mcTemp);
}
testLoad(loadID);
//

// Kenneth Kawamoto (on the road)
// materia prima limited
// [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
// www.materiaprima.co.uk <http://www.materiaprima.co.uk>

thanks for your suggestion, still I cant get it to work. all I am trying to
acomplish is a preloader that will load files in order so if it is done with
1 then load the next one and so forth. I have found some information in how
to load 5 files at the same time.

Also I was able to call the function from different buttons but for some
reason when I try to call a new function onLoadComplete it seems to make the
player to choke and get confused.

Thanks again

On 9/7/06, Peter O'Brien <[EMAIL PROTECTED]> wrote:
try subbing your code from onLoadComplete to an onLoadInit function, that
looks like it should do the trick

On 9/7/06, Helmut Granda <[EMAIL PROTECTED]> wrote:
Can the MovieClipLoader class be reused?

I have the following code:

var myMCL:MovieClipLoader = new MovieClipLoader();
var myListener:Object = new Object();

myListener.onLoadComplete = function(targetMC:MovieClip):Void {
   trace("loaded" + targetMC);
   myMCL.loadClip("right2.swf", "img2");//-->This makes the Movie Loop
and
never load the next item.
}

myListener.onLoadStart = function(targetMC:MovieClip):Void {
   //targetMC.stop();
   trace("Started");
}

myListener.onLoadProgress = function(targetMC:MovieClip):Void {
   trace("In Progress");
}

this.attachMovie("img", "img", 50);
this.attachMovie("img", "img2", 51);

myMCL.addListener(myListener);
myMCL.loadClip("right1.swf", "img");

//------
It is straight forward, creae a Loader as well as an object and it works
great for the first load, but once I fire the next load it fails.
Basiclly
what I want to do is have an array with different movies that will load
to
the users cache for later use.

TIA.


_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to