preloader script
Copy link to clipboard
Copied
I'm trying to build a preloader.
I made a scene in the FLA called preloader and inserted the following script.
The problem is that I got the preload animation and the script from 2 different tutorials.
The problem I think lies in the fact that I think the code I am using requires a 100 frame animation, and I am only using a 25 frame animation.
I tried adding frames to the animation to make it 100 frames , but it still doesn't work.
--I followed the scripting instructions from this tutorial
http://www.flashmagazine.com/Tutorials/detail/how_to_make_a_custom_as3_preloader/
--I got the preload animation from this one. Though I am only using the animation, not the dynamic text field.
http://active.tutsplus.com/tutorials/web-design/create-an-apple-inspired-flash-preloader/
Here is an attachment with the FLA, and the code in the preloader scene is below.
Any help is appreciated. Thanks
----------
import flash.events.ProgressEvent;
function update(e:ProgressEvent):void
{
var percent:Number = Math.floor( (e.bytesLoaded*100)/e.bytesTotal );
if(preloaderMC is MovieClip){
preloaderMC.gotoAndStop(percent);
}
if(percent == 100){
play();
}
}
loaderInfo.addEventListener(ProgressEvent.PROGRESS, update);
// Extra test for IE
var percent:Number = Math.floor( (this.loaderInfo.bytesLoaded*100)/this.loaderInfo.bytesTotal );
if(percent == 100){
nextFrame();
}
stop();
Copy link to clipboard
Copied
don't add any unneeded frames to preloaderMC and use:
function update(e:ProgressEvent):void{
var fraction:Number = e.bytesLoaded/e.bytesTotal;
preloaderMC.gotoAndStop(Math.ceil(fraction*preloaderMC.totalFrames));
}function loadCompleteF(e:Event){
play();
}
loaderInfo.addEventListener(ProgressEvent.PROGRESS, update);
loaderInfo.addEventListener(Event.COMPLETE, loadCompleteF);
stop();
Copy link to clipboard
Copied
Thanks, though I put this script in and it doesn't seem to be working.
I uploaded the .swf with the preloader and this script on to the site, but the area is still white while it's loading and then it plays the actual scene.
Am I doing something wrong?
Copy link to clipboard
Copied
your preloader won't display until all items designated to load in frame 1, have loaded. that includes all classes and embedded fonts so, if you have a lot of those things, you're not doing anything wrong. that's just expected with an internal preloader and your setup.
otherwise, you're doing something wrong.
Copy link to clipboard
Copied
the preloader is pretty simple just a 25 frame movie clip vector animation, no text and your script.
I'm supposed to put that code in frame 1 of the preloader scene ---right? Not the main scene.
Copy link to clipboard
Copied
if you're using scenes, the preloader and preloader code should be in the first frame of the first scene. what you call your scenes is irrelevant.

