3 Replies Latest reply: Jul 6, 2008 9:36 AM by kglad RSS

    Sleep / Wait / Pause functions in AS2.0?

    terablade2001 Community Member
      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 ....
      while(flag == 1) {
      // .... 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!