Flash AS3 Tutorials Center | Interesting Flash Animation Tutorials | Valuing Flash Animation Tutorials | Flash ActionScript and Animation Home

AS3 Beginner Tutorials | AS3 Basic Lessons | AS3 Valuing Courses | AS3 Components Tutorials | AS3 and PHP Interaction Tutorials
AS3 Practical Tutorials | AS3 Animation Techniques | AS3 Transition Effects Tutorials | AS3 Download Upload Files | AS3 Particle Systems
Communication Between Flash Movies with AS3 | AS3 and JavaScript interaction | AS3 Matrix Transformation | AS3 Physics Simulation Tutorials

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.

Please update flash player to view this Flash ActionScript tutorial!

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 {

var myRequest:URLRequest=new URLRequest("glow.swf");
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 {

var myRequest:URLRequest=new URLRequest("down.swf");
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{

if (imageLoaded == true) {
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:

Flash Source File load-swf-1.fla

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.