actionscript 3 を使用している可能性があるため、間隔をまったく使用しないことをお勧めします。Timer オブジェクトは、より適切な制御を提供できるため、より優れている可能性があります。たとえば、停止する前に起動する回数を設定でき、必要に応じてタイマーを簡単に開始、停止、再起動できるなどです。
Timer オブジェクトを使用し、各ティックにイベント リスナーを追加する例
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);
タイマーの制御:
timer.start(); // start the timer
timer.stop(); // stop the timer
timer.reset(); // resets the timer
それがスローする2つのイベント:
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)
API ドキュメント: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/utils/Timer.html