2 Replies Latest reply on Jun 21, 2007 6:44 AM by kglad

    How do you manage timers?

    Rusherific
      What are your guys' methods of using timers? Currently I'm going through the whole process of constructing new timers and eventlistener functions every time I need to animate or delay something, which means a lot of unique and creatively named variables, but is there a better way like being able to use one running timer for my whole project (I wouldn't mind working with one time interval) that functions can jump in and out of at will?

      Thanks
        • 1. How do you manage timers?
          ocbfd Level 1
          You could make an array of times and use an interval-driven function to check those times using getTimer as main movie clock.

          getTimer() - returns the milliseconds that have elapsed since the swf started playing

          Here's quick example of using interval to check getTimer(). Always remember to use "updateAfterEvent()" to free your function up to run faster than your fps.

          //
          function showTime(){
          trace(getTimer()/1000);
          updateAfterEvent();
          };
          //
          intShowTime = setInterval(showTime,10);
          //
          • 2. Re: How do you manage timers?
            kglad Adobe Community Professional & MVP
            this is an as3 question.

            as in as2, i use one main loop calling one main function. within that function i call the other functions that need to repeatedly execute.

            if some of those other functions only need to be called every other cycle i use an if-statement checking when timer.currentCount%2 is one (or zero). likewise, if some functions need to be called every nth cycle, i check timer.currentCount&n.