Listening for Timer Events : Timer Event : Animation Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » Animation » Timer Event »

 

Listening for Timer Events


 
package {
    import flash.display.Sprite;
    import flash.utils.*;
    import flash.events.*;
    public class Main extends Sprite {
        public static const TIMER_DELAY:Number = 1000;
        public var timer:Timer = new Timer(TIMER_DELAY, 10);

        public function Main() {
            timer.addEventListener(TimerEvent.TIMER, onTimer);
            timer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);
        }
        private function onTimer(event:TimerEvent):void {
            trace("Tick.");
        }
        private function onTimerComplete(event:TimerEvent):void {
            trace("Ding!");
        }
    }
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo Animation
» Timer Event