views:

20

answers:

1

Hi, I'm using the following actionscript for my flash preloader, what this does is have the preloader bar fill from the top to the bottom.

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;

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

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

How would I alter this so that instead, it starts off full and then decreases in size down to zero (downwards)?

Thanks

+1  A: 

Inverse the scaleY value. loaded/total will going from 0 to 1, so doing 1 - loaded/total it will going from 1 to 0, and the your preloader will shrink instead of growing :

preloader_mc.bar_mc.scaleY = 1 - loaded/total;
Patrick
Perfect, thanks for the help, and the explanation.
Probocop