PDA

View Full Version : Preloader progress bar calculation


rockman82
03-07-2007, 04:20 AM
Could someone please tell me what is wrong with this code? I'm making a preloader bar ("loaderbar" in the code) which will extend from 0 pixels to 165 pixels when the load progress reaches 100%. Then the playhead will move to frame 2, triggering the animation, buttons, etc. to be displayed. Right now, nothing quite works, and I haven't found the probelm. Also, if there is a simpler or more efficient way to do this, it would be much appreciated. Thanks.



_root.stop();

_global.Y = 0;

function loadprogress () {
_global.Y = Math.ceil(getBytesLoaded() / getBytesTotal());
_root.loader.loaderbar._width = (_global.Y)*(165);
updateAfterEvent();
};
loadinterval = setInterval (loadprogress, 50);

if (_global.Y >= 1) {
clearInterval (loadinterval);
_root.gotoAndStop(2);
};

daryl
03-07-2007, 04:57 AM
your (getbytesloaded / getbytestotal) will always be a fraction, so your Math.ceil will always return 1.

I think you want to put your ceil around the expression ((_global.Y)*(165))

rockman82
03-07-2007, 06:40 AM
It still doesn't do anything. It appears that the function isn't working at all. The movie won't even go to frame 2.