Hi.
I wanted to ask, if there is any easy way to make my code stop executing until
I set up a flag.
A basic example of what I want to is:
// .... code 1 ....
flag=1;
while(flag == 1) {
[b]Sleep[/b](500);
}
// .... code 2 ....
The "code 2" need to start executing if "flag" is set to 0 with some interval,
or listener.
Still, if I use just:
while (flag==1);
I will consume all CPU power without any reason.
Is there any Flash function that will prevent code execution of current script
from a predefined time (i.e. 500msec) without consuming CPU usage?
If not, is there any other way?
I could use setInterval() but then the "code 2" should be written in the
Interval function, and I don't want that because it will mess up all my codes!
Thanks.
padideh2 - 06 Jul 2008 16:33 GMT
hi
you need use from inerval and call function whit (setInterval)
and when you want to stop function use (clearInerval)
terablade2001 - 06 Jul 2008 16:54 GMT
Hi m8.
Yea, I know that - this is the way I am creating my project.
But with the interval function you have to break your code to 2 functions: One
of your main function, one on the interval function (to be executed after the
flag change). And this mess up the code, specially if we talk about 500-1000
lines of code in an object which need to check with 3-5 flags with logical
combination with those flags... too messy.....! :P
Still intervals seems to be the only way. :)
Still hoping someone to find another!!!... AS2.0 should have a "sleep" or
"pause" or "wait" function that will make the object's called code to stop
executing for some milliseconds. This would come very handy! :)
kglad - 06 Jul 2008 17:36 GMT
there is no sleep/pause/wait function in as2 (or as3).