Reputation: 3
I dont know how to show the current progress in progressBar component when the process is a loop that requires a lot of seconds to do the job. Inside the loop, i setProgress and update the progressBar label in every cicle, but it is not shown up to the job is done. I dont need this, because i want to see the advance of process. thank you.
Upvotes: 0
Views: 2063
Reputation: 2238
It is possible, just instead for or while you need to use Timers.
import flash.utils.Timer;
import flash.events.TimerEvent;
var loopNum : uint = 17598; // loop length ( forrmer for or while limit )
var tick : uint = 0;
var timer:Timer = new Timer ( 10, loopNum );
timer.addEventListener ( TimerEvent.TIMER, handleLoopTick );
timer.start ();
function handleLoopTick ( e : TimerEvent )
{
trace ( this, ( tick / loopNum ) * 100 ); // outputs percentage for example
tick++; // increasing the tick
}
Upvotes: 0
Reputation: 14221
If you mean an ordinary loop like for
or while
the answer is: it is impossible. Loops in Flash are synchronous but all the animations (including programming) are frame based asynchronous. So the only way is to distribute your loop across multiply frames.
Upvotes: 1