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 Flash swf File with Text Preloader

You should have the experience of waiting some external swf file to load up, but not knowing how long have to wait. This is always good to let the users know how long have to wait for the external Flash swf file to load up. A preloader is the best solution.

Please update flash player to view this Flash ActionScript tutorial!

Flash Tutorial Content:

Sometimes the loading time of the external swf file is quite long. Therefore this is better to show to your visitor the progress of the loading. Otherwise your visitors may think your website is dead. This Flash ActionScript tutorial shows how to make the most simple Preloader, a text Preloader.

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

Flash ActionScript Codes:

//Declare the loading percentage
var percent:Number;

 

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

 

// URL of the external movie content
var myRequest:URLRequest=new URLRequest("calculate-current.swf");

 

// Load the external movie into the Loader
myLoader.load(myRequest);


//Listen to the progress of the loading
myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadingProgress);

 

function loadingProgress(evt:ProgressEvent) {

//Calculate the loading percentage
percent = Math.round((evt.bytesLoaded/evt.bytesTotal) * 100);

//Display the loading percentage to visitors
//Actually you can use AS to add the TextField dynamically
percentLoaded_txt.text = "Loading picture.... " + String(percent) + "% loaded";

}

 

// 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 = 40;
myLoader.y = 37;

//Hide the loading progress text that no longer in use
percentLoaded_txt.visible = false;

}

Download Flash Source File:

Flash Source File load-swf-6.fla

Remarks:

This Flash ActionScript tutorial shows the progress of loading external Flash swf file with a preloader.