Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Since it seems like you may be using actionscript 3, I suggest not using an interval at all. A Timer object may be better as it can offer better control, such being able to set the number of times it fires off before stopping itself and being able to easily start, stop, and restart the timer as needed.</p> <p>Example of using a Timer object and adding an event listener for each tick</p> <pre><code>import flash.utils.Timer; import flash.events.TimerEvent; // each tick delay is set to 1000ms and it'll repeat 12 times var timer:Timer = new Timer(1000, 12); function timerTick(inputEvent:TimerEvent):void { trace("timer ticked"); // some timer properties that can be accessed (at any time) trace(timer.delay); // the tick delay, editable during a tick trace(timer.repeatCount); // repeat count, editable during a tick trace(timer.currentCount); // current timer tick count; trace(timer.running); // a boolean to show if it is running or not } timer.addEventListener(TimerEvent.TIMER, timerTick, false, 0, true); </code></pre> <p>Controlling the timer:</p> <pre><code>timer.start(); // start the timer timer.stop(); // stop the timer timer.reset(); // resets the timer </code></pre> <p>Two events it throws:</p> <pre><code>TimerEvent.TIMER // occurs when one 'tick' of the timer has gone (1000 ms in the example) TimerEvent.TIMER_COMPLETE // occurs when all ticks of the timer have gone (when each tick has happened 11 times in the example) </code></pre> <p>API Documentation: <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/utils/Timer.html" rel="nofollow">http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/utils/Timer.html</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload