PDA

View Full Version : Setting up a basic progress bar


adaykin
08-17-2008, 01:30 AM
Hey, I am trying to setup a basic progress bar that moves from 1 to 100%, and reflects that in a label too. However my label moves from 1 to 100 without reflecting any of the numbers in between.


private function runBar():void
{
setTimeout(moveBar, 2000);
}

private function moveBar():void
{
var i:int;
for(i = 0; i <= 100; i++)
{
progressBar.setProgress(i, 100);
progressBar.label= "CurrentProgress" + " " + i + "%";

trace(i);
}
runBar();
}

Stealth86
08-19-2008, 06:11 PM
A for loop like this will execute far too quickly for you to see any numbers other than 1 and 100 on the label.

Also, you have a rather nasty bug in your code. The call to runBar() at the end of moveBar will cause a nasty infinite loop that will leak memory. :o

drkstr
08-19-2008, 06:54 PM
What determines your progress? Your code just shows the progress of a loop from 0 to 100 (not to mentioned the bug). Are you trying to show some download progress, the execution of a large algorithm, or something else entirely? You will need to answer this question to solve your problem, but essentially need to advance your progress bar relative to the actual progress.


Best Regards,
~Aaron