PDA

View Full Version : animated Preloader



Daimz
October 27th, 2009, 06:48 AM
Hi I am wanting to make a very basic preloader that basicly shows the % loaded in type and then also gradually reveals the logo. Now I use to know how to do this in AS2 using masks but I have not been able to do it in AS3 and I haven't found any tutorials on it either.

I have got this code:

stop();

this.addEventListener(Event.ENTER_FRAME, loading);

function loading(e:Event):void {

var total:Number = this.stage.loaderInfo.bytesTotal;
var loaded:Number = this.stage.loaderInfo.bytesLoaded;

bar_mc.scaleX = loaded/total;
loader_txt.text = Math.floor((loaded/total)*100)+ "%";

if (total == loaded) {
play();
this.removeEventListener(Event.ENTER_FRAME, loading);
}

}
How can I tweak this do do what I am wanting? Oh and I am loading external swf's in to a loader.

Daimz
November 5th, 2009, 02:21 AM
does anybody have any ideas. I have like 2 day before my assignment needs handing in.

IQAndreas
November 5th, 2009, 05:46 AM
Hm... This isn't the most efficient way, but it will be easier for you to implement and understand.

Create a new movieClip out of your logo. Put 100 frames inside of that mc, and tween and mask or whatever you want to do on it so frame 1 makes it completely masked, and frame 100 has it completely visible.

Then, in the "loading" function, just add something quick like this:
logoMC.gotoAndStop(loaded/total * 100);

You can even add a Math.round() or int() in there, but I don't think it will matter.