all groups > flash actionscript > february 2005 >
You're in the

flash actionscript

group:

interupting a "for" instruction


Re: interupting a "for" instruction David Stiller
2/8/2005 5:11:00 PM
flash actionscript:
Brenda,

You could set a boolean variable and have your for() loop check it once
every loop. When a user clicks the button, set the variable to false and
have your for() loop return.


David
stiller (at) quip (dot) net
"Luck is the residue of good design."



[quoted text, click to view]

interupting a "for" instruction bso_71
2/8/2005 9:22:26 PM
Can I interrupt a ' for(i=1;i<=10;i++)' instruction if my user clicks on a button?

Thanks!

Re: interupting a "for" instruction Byron Canfield
2/8/2005 9:46:21 PM
[quoted text, click to view]
button?

For loops and while loops cannot be used as timing devices to impose delays
(during which user might click). You'll need to use an onEnterFrame
function, a setInterval function, or apply on onClipEvent(enterFrame) to a
movieclip, or use a multi-frame loop, either on the main timeline or in a
movieclip.


--
--------
Reality will not be altered to comply with preconceived notions.

Byron "Barn" Canfield

Re: interupting a "for" instruction abeall
2/8/2005 10:22:20 PM
Well you can use a 'break' command to escape a loop, but understand that there
will be no user interaction during a for loop, as a for loop is completed all
in one frame. In other words, a for() loop is an instantaneous event, not an
ongoing process. Could you give an example of what needs to be interrupted?
anotherVar = random(10); for(i=1 ; i<=10 ; i++){ if(i==_root.anotherVar){
break; } trace(i); }
Re: interupting a "for" instruction David Stiller
2/9/2005 8:14:01 AM
Ouch! Thanks for the info, Jeckyl. I am amending my mental notes.
Sorry, Brenda, for an incorrect reply.


David
stiller (at) quip (dot) net
"Luck is the residue of good design."




[quoted text, click to view]

Re: interupting a "for" instruction Jeckyl
2/9/2005 9:18:09 AM
No .. you cannot break it, because the for loop script executes completely
before the button processing happens. Only one script can really be running
at a given time in Flash.
--
All the best,
Jeckyl

Re: interupting a "for" instruction InternetInfinity
2/9/2005 5:38:07 PM
There are two way to interact with a for loop statement :

break;
and
continue;

AddThis Social Bookmark Button