Home | Flash AS3 Tutorials | Flash Animation Tutorials | Store

Flash ActionScript 3 Tutorial: Error Appear During Loading External Flash swf Movie

In previous Flash ActionScript tutorial, the external swf file was displayed when the loading process was completed. This come another question. What if an error happens during the loading process?

Please update flash player to view this Flash ActionScript tutorial!

Flash Tutorial Content:

Sometimes errors may happen during the loading process, 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 ActionScript codes.

The complete Flash Movie is shown as above, you may try how it works before you start this Flash tutorial. The file name of the external swf file is wrong due to typing mistake. Therefore the external swf Flash Movie cannot be displayed on the MainTimeline. An annoying error message box may pop up. However the user do not know what happens.

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
// Wrong file name of the external swf file
var myRequest:URLRequest=new URLRequest("glow2.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-3.fla

Remarks:

This Flash ActionScript tutorial shows that the external swf file cannot be displayed when there is an error during the loading process. An annoying error message box may pop up. The users do not know what happen. Therefore this is better to inform the users that an error happens for the Flash Movie. And the users can inform the website Administrator about the error. The next Flash ActionScript tutorial will show how to do that.