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 External swf Flash Movie with COMPLETE Event

The first flash ActionScript tutorial simply loaded the external swf movies into the main Flash Movie assume that everything goes well. However a better approach is to monitor the whole loading process of the external swf movies. This include when the loading is completed? What if an error happens during the loading process? How to inform the users when errors happen during the loading process. This Flash ActionScript tutorial shows how to listen when the loading is completed?

Please update flash player to view this Flash ActionScript tutorial!

Flash Tutorial Content:

The codes in previous Flash ActionScript tutorial was blindly load the external swf files and display them on the MainTimeline assume that everything went well. A little better approach is to display the external swf file only when the loading process is completed.

The complete Flash Movie is shown as above, you may try to play around how it works before you start this Flash ActionScript tutorial.

Flash ActionScript Codes:

// Create a new Loader to load the swf files
var myLoader:Loader=new Loader();

function checkComplete(evt:MouseEvent) {

// URL of the external movie content
var myRequest:URLRequest=new URLRequest("glow.swf");
// Load the external movie into the Loader
myLoader.load(myRequest);

}

 

movie1_btn.addEventListener(MouseEvent.CLICK, checkComplete);

// Listen when the loading of movie (glow.swf) is completed
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadMovie1);

function loadMovie1(myEvent:Event):void {

// Display the Loader on the MainTimeline when the loading is completed
addChild(myLoader);
// Set display location of
myLoader.x = 200;
myLoader.y = 80;

}

Download Flash Source File:

Flash Source File load-swf-2.fla

Remarks:

This Flash ActionScript tutorial shows how to listen when the loading process is completed. The above codes will display the external swf file when the loading process is completed. However sometimes errors may happen, for example, you change the file names of the external movies but forget to update the codes. Therefore this is always better to include error checking in your codes. The next Flash ActionScript tutorial will show how to do that.