How To Loop Sequence of Loaded SWF Files?
READY! Here it is : We have a simple but useful code that loads 2 swf files in sequence ...
But How can I Loop it?
How can you change the code to load swf1 after swf2 is finished?
I've tried almost the whole day but no result yet... Please help...Even with your comments any any any idea is greatly appreciated.
Thanks a lot...
Here is the code:
import com.greensock.*;
import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;
import flash.events.Event;
//create SWFLoaders
var swf1:SWFLoader = new SWFLoader("child1.swf",{container:this,y:100,onProgress:progressHandler,onComplete:completeHandler,autoPlay:false});
var swf2:SWFLoader = new SWFLoader("child2.swf",{container:this,y:100,onProgress:progressHandler,onComplete:completeHandler,autoPlay:false});
var currentSWFLoader:SWFLoader = swf1;
//adjust the progress bar;
function progressHandler(e:LoaderEvent😞void {
bar.scaleX = e.target.progress;
trace(e.target.progress);
}
//tell the loaded swf to play and start tracking frames
function completeHandler(e:LoaderEvent😞void {
//the target of the LoaderEvent is the SWFLoader that fired the event
//the rawContent is the loaded swf
e.target.rawContent.play();
addEventListener(Event.ENTER_FRAME, checkFrame);
}
function checkFrame(e:Event😞void {
//check to see if loaded swf is done playing
if (currentSWFLoader.rawContent.currentFrame == currentSWFLoader.rawContent.totalFrames) {
trace("swf done playing");
removeEventListener(Event.ENTER_FRAME, checkFrame);
//if the first swf is done playing load the second swf
if (currentSWFLoader == swf1) {
currentSWFLoader.dispose(true) // dispose and unload content
currentSWFLoader = swf2;
currentSWFLoader.load();
}
}
}
bar.scaleX = 0;
currentSWFLoader.load();
