OK, this is getting a bit complicated...
Code:
// AS2 main timeline
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 {
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);
stop();
//
What I get in the Output is as follows:
[tt]
SWF: file:///D|/flash/sequential%5Fload/1.swf
totalBytes: 313701
grossBytes so far: 313701
***
SWF: file:///D|/flash/sequential%5Fload/2.swf
totalBytes: 15496
grossBytes so far: 329197
***
SWF: file:///D|/flash/sequential%5Fload/3.swf
totalBytes: 198600
grossBytes so far: 527797
***
SWF: file:///D|/flash/sequential%5Fload/4.swf
totalBytes: 233
grossBytes so far: 528030
***
SWF: file:///D|/flash/sequential%5Fload/5.swf
totalBytes: 518
grossBytes so far: 528548
***
Final grossBytes: 528548
***
Start sequential loading
***
Currently loading file:///D|/flash/sequential%5Fload/1.swf
Bytes loaded so far: 65732
12.43%
***
Currently loading file:///D|/flash/sequential%5Fload/1.swf
Bytes loaded so far: 131314
24.84%
***
Currently loading file:///D|/flash/sequential%5Fload/1.swf
Bytes loaded so far: 196971
37.26%
***
Currently loading file:///D|/flash/sequential%5Fload/1.swf
Bytes loaded so far: 262645
49.69%
***
Currently loading file:///D|/flash/sequential%5Fload/1.swf
Bytes loaded so far: 313701
59.35%
***
Load completed for file:///D|/flash/sequential%5Fload/1.swf
***
Currently loading file:///D|/flash/sequential%5Fload/2.swf
Bytes loaded so far: 329197
62.28%
***
Load completed for file:///D|/flash/sequential%5Fload/2.swf
***
Currently loading file:///D|/flash/sequential%5Fload/3.swf
Bytes loaded so far: 527797
99.85%
***
Load completed for file:///D|/flash/sequential%5Fload/3.swf
***
Currently loading file:///D|/flash/sequential%5Fload/4.swf
Bytes loaded so far: 528030
99.9%
***
Load completed for file:///D|/flash/sequential%5Fload/4.swf
***
Currently loading file:///D|/flash/sequential%5Fload/5.swf
Bytes loaded so far: 528548
100%
***
Load completed for file:///D|/flash/sequential%5Fload/5.swf
***
All loadings completed!
[/tt]
You can see SWFs are loaded sequentially and the loaded percentage is accumulated to 100%.
I would not say this code is complete, as I didn't put any error handling, but I hope you'll get the basic idea.
Kenneth Kawamoto