flash actionscript:
how can I pause a FOR loop for X secs/msecs before continueing with the next run ? Something like this for(i=0;i<5;i++){ //DO SOME CODE PAUSE(500);
You can't ... that makes no sense in a flash environment. Instead either: * split your processing over frames (have a set of frames that loop) * use an onEnterFrame * use a setInterval -- Jeckyl
Ok i just give it a go. logic which i thought loop starts met a condition > pause start (no increment in loop) time reached and start again Can anyone help what i am doing wrong var intervalID:Number; // to store interval id var flag:Boolean = false; // track execution of for loop var pauseInterval:Number = 5; //time to pause loop var counter:Number = 0; //increment counter for time check var bool:Boolean = false; // to ensure fPause function execute only once. var i:Number = 1; //loop variable while (i <= 20) { if (i == 10) { //after 10 loop should be paused if (!bool) { fPause(pauseInterval); //call function to pause bool = true; // should not execute again } } if (!flag) { // normal tracing if pause not encountered trace(i); i++; } } //pause function function fPause(interval) { flag = true; intervalID = setInterval(track, 1000); } //check pause interval is reached function track() { counter++; if (counter == pauseInterval) { // condition met now start the loop flag = false; i++; clearInterval(intervalID); } }
Don't see what you're looking for? Try a search.
|