Having problems with your preloader? It's to be expected. Preloaders have a history of causing a lot of grief among Flash designers. Even once you get the loader bar working, you'll often find that it takes the preloader itself several seconds before it shows up. Which defeats the purpose of having a preloader in the first place. So you dive in deeper and quickly discover that there are a dozen tweaks that have to be made just to get your preloader to show up quicker.

In today's free ActionScript tutorial, you'll learn a better way to create preloaders--a way that doesn't require a bunch of workarounds to get it functioning properly! Enjoy!

Here's the code from the tutorial:

 
myLoader.addEventListener(Event.COMPLETE, onComplete);
myLoader.addEventListener(ProgressEvent.PROGRESS, onProgress);
 
function onProgress(e:ProgressEvent):void
{
	var pct:Number = e.bytesLoaded / e.bytesTotal;
	preloader_mc.bar_mc.scaleX = pct;
}
 
function onComplete(e:Event):void
{
	preloader_mc.x = -1000;
}
 
myLoader.load(new URLRequest("berries.swf"));
 

Click here for more comprehensive Flash tutorials