how to load a movie[.swf] at the end of another movie[.swf] in AS3?
thanks
how to load a movie[.swf] at the end of another movie[.swf] in AS3?
thanks
The easiest way is to do something like this on the last frame of your movie clip:
var myLoader:Loader = new Loader();
addChild(myLoader);
var url:URLRequest = new URLRequest("myExternalMovie.swf");
myLoader.load(url);
But the best way is to use something like this to listen for the end of the last movie clip:
if (mc1.currentFrame == mc1.totalFrames) {
//code to load next movie clip
}
Use the currentFrame and totalFrames to find if the first clip is done playing.
Use this to create a MovieClip Instance:
var mc:MovieClip = new MovieClip();
//properties code here (just his .)
addChild(mc);
here is a piece of code which i got when i googled around,and it works. i havnt got the guy's name but he saved the day 4 me
// Array of external clips to use. Variable index refers to next clip to be displayed.
var clips:Array = ["check.swf","02.swf"]; var index:int = 0;
// Stuff for loading files var thisLoader:Loader = new Loader(); thisLoader.contentLoaderInfo.addEventListener(Event.INIT, doneLoading);
var thisMC:MovieClip = new MovieClip(); stage.addChild(thisMC); // Add empty MC initially so the nextClip function works even on first call
// Gets the next MC, waiting for INITialization before adding it to the stage
function nextClip():void { thisLoader.load( new URLRequest(clips[index]) ); }
// Remove old clip, tell AS that the loaded file is the new one, add it to the stage, and play. function doneLoading(e:Event):void { stage.removeChild(thisMC); thisMC = MovieClip(thisLoader.content); thisLoader.unload(); thisMC.addEventListener(Event.ENTER_FRAME, runOnce); stage.addChild(thisMC); thisMC.gotoAndPlay(1); }
// When currentFrame equals totalFrames in loaded clip (playing), increment index & play the next clip. function runOnce(e:Event):void { if (thisMC.currentFrame == thisMC.totalFrames) { thisMC.removeEventListener(Event.ENTER_FRAME, runOnce); index = (index + 1)%(clips.length); nextClip(); } }
// Call nextClip to automatically start the first clip
nextClip();