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.
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) {
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 {
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:
Remarks:
This Flash ActionScript tutorial shows the progress of loading external Flash swf file with a preloader.