Google
 
Webnews.only-4-geeks.com
Interesting places
news.only-4-geeks.com Forum Index » Flash - ActionScript

Sleep / Wait / Pause functions in AS2.0?

 
Jump to:  
 
terablade2001
PostPosted: Sun Jul 06, 2008 11:00 am    Post subject: Sleep / Wait / Pause functions in AS2.0?
       
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) {
Sleep(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
PostPosted: Sun Jul 06, 2008 3:33 pm    Post subject: Re: Sleep / Wait / Pause functions in AS2.0?
       
hi
you need use from inerval and call function whit (setInterval)
and when you want to stop function use (clearInerval)
 

 
terablade2001
PostPosted: Sun Jul 06, 2008 3:54 pm    Post subject: Re: Sleep / Wait / Pause functions in AS2.0?
       
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! Smile
 

 
kglad
PostPosted: Sun Jul 06, 2008 4:36 pm    Post subject: Re: Sleep / Wait / Pause functions in AS2.0?
       
there is no sleep/pause/wait function in as2 (or as3).
 

Page 1 of 1 .:.

Google
 
Webnews.only-4-geeks.com

Windows Update | C++ | C | PHP | JavaScript | Photoshop | Programming | Windows 2000 | Python | Windows XP | Object | Flash | Flash - ActionScript | Paint Shop Pro | Excel | PowerPoint | Access | Word | Windows 98 | Internet Explorer 6.0 | CorelDraw12 | Java | XML | asm x86 | Linux Mandrake | Linux RedHat | Outlook |  | news from newsgroups |_ | s

Web Templates

Awesome Website Templates ©

trwa pobierania linkow oczekiwanie na linki wymiana linkow proces pobierania linkow pobieranie linkow