Flash ActionScript 3 Tutorial: Load Multiple External Flash swf Movies
For some reasons, you may require to save some your swf movies outside the main Flash Movie. The external swf movies will be loaded into the MainTimeline or stage of the main Flash Movie when play.
Flash Tutorial Content:
Most people simply load external Flash swf files or Flash Movies into the Main Flash Movie assume that everything is going well. The codes are very simple if you wish to do that.
The complete Flash Movie is shown as above, you may try how it works before you start this Flash ActionScript tutorial. It simply loads two different external swf Flash Movies on the MainTimeline with a Loader but with two different buttons. It also shows how to remove the Loader
Flash ActionScript Codes:
var imageLoaded:Boolean = false;
// Create a new Loader to load the swf files
var myLoader:Loader=new Loader();
// Set the location of the new Loader
myLoader.x=200;
myLoader.y=80;
// function to load the Flash Movie 1 "glow.swf"
function loadMovie1(evt:MouseEvent):void {
myLoader.load(myRequest);
addChild(myLoader);
// Set imageLoaded to true so that the Image can be unloaded
imageLoaded = true;
}
movie1_btn.addEventListener(MouseEvent.CLICK, loadMovie1);
// function to load the Flash Movie 2 "down.swf"
function loadMovie2(evt:MouseEvent):void {
myLoader.load(myRequest);
addChild(myLoader);
// Set imageLoaded to true so that the Image can be unloaded
imageLoaded = true;
}
movie2_btn.addEventListener(MouseEvent.CLICK, loadMovie2);
// Function to remove the Loader
function removeMovie(evt:MouseEvent):void{
myLoader.unload();
removeChild(myLoader);
// Set imageLoaded to false to prevent error when no Image loaded
imageLoaded = false;
}
}
remove_btn.addEventListener(MouseEvent.CLICK, removeMovie);
Download Flash Source File:
Remarks:
This Flash ActionScript tutorial shows how to load external Flash swf Movie. The above codes works well if everything goes well. It will blindly load the external swf files and display them on the MainTimeline assume that everything goes well. A little better approach is to display the external swf file only when the loading process is completed. The next Flash ActionScript will show how to do that.