ActionScript 3 Tutorial – A Better Preloader
Flash Tutorial October 9th, 2009Having 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"));


October 22nd, 2009 at 10:38 am
Is there a way to change the download settings in CS3 to test with a simulation? Unfortunately, I don’t have CS4.
January 9th, 2010 at 9:48 pm
Thanks a lot for such important source code. It’s really helpful and needed.
April 6th, 2010 at 9:41 pm
Hi before anything, thanks or the post it’s really useful.
But i have a problem with your code, personally im loading the swf of the same site on the web, and it marks aproblem of a Sandbox. I have tried to allow the domain security and it still dosent work.
Maybe you know whats the problem.Thanks for the help, this is the code.
stage.displayState = StageDisplayState.FULL_SCREEN;
myLoader.load(new URLRequest(“http://devocionpreciosisimasangre.com/contenido.swf”));
myLoader.addEventListener(Event.COMPLETE, onComplete);
myLoader.addEventListener(ProgressEvent.PROGRESS, onProgress);
Security.allowDomain(“http://devocionpreciosisimasangre.com/”);
Security.allowInsecureDomain(“http://devocionpreciosisimasangre.com/”);
Security.LOCAL_TRUSTED;
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;
}
April 6th, 2010 at 9:43 pm
Sorry the code i posted is another i tried, where i put the swf on another site so i dosent make the same problem, but still isn’t working.
Thanks