Change text value in a TextField in a timer : Timer : Animation Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » Animation » Timer »

 

Change text value in a TextField in a timer


 

package {

    import flash.display.Sprite;
    import flash.text.TextField;
    import flash.utils.Timer;
    import flash.events.TimerEvent;

    
    public class Main extends Sprite {
        var timer:Timer = new Timer(1000);
        
        private var _text:TextField;
        private var _start:uint;
        
        public function Main(  ) {
            _start = 0;
            _text = new TextField(  );
            addChild(_text);
            timer.addEventListener(TimerEvent.TIMER, onTimer);
            timer.start(  );
        }
        
        private function onTimer(event:TimerEvent):void {
            _text.text = (timer.currentCount - _start" milliseconds";
        }
        
    }
}

        



Leave a Comment / Note


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


Flash / Flex / ActionScript examples

 Navioo Animation
» Timer