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: Handle Error During Loading External Flash swf File (1)

As we seen from previous Flash ActionScript tutorial, error might happen during the loading process. Therefore this is better to inform users that some problem happens during the loading process.

Please update flash player to view this Flash ActionScript tutorial!

Flash Tutorial Content:

The external swf file will not be displayed when there is an error during the loading process. Therefore this is better to inform the users that an error happens for the Flash Movie. And the users in turn can inform website Administrator about the error.

The complete Flash Movie is shown as above, you may try how it works before you start this 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. Unlike previous tutorial, the error message will be shown on the message box.

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



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
// Set display location of
myLoader.x = 200;
myLoader.y = 80;



// Listen error events for the loading process
myLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loadError);
myLoader.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, loadError);

function loadError(event:ErrorEvent):void {

// Display error message to user in case of loading error.
output_txt.text = "Sorry that there is an error during the loading of an external movie. The error is:" + "\n" + event;


Download Flash Source File:

Flash Source File load-swf-4.fla


The above ActionScript codes will check both IOErrorEvent and SecutiryErrorEvent when an error happens. Some people would like to check the error in two steps. The first step will check with IOErrorEvent. If there is no any error with IOErrorEvent, then try to load the external swf file into the Loader. If there is an error at this stage, the SecurityErrorEvent error message will be displayed. Otherwise the external swf movie will be displayed. The next Flash ActionScript tutorial will show how to do that.