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";
}
}
}
Related examples in the same category