/ Published in: ActionScript 3
delay is in milliseconds. repeat must be set to at least 1.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
import flash.utils.Timer; import flash.events.TimerEvent; import flash.events.Event; private var myTimer:Timer = new Timer(delay, repeat); myTimer.addEventListener(TimerEvent.TIMER, timerHandler); myTimer.addEventListener(TimerEvent.TIMER_COMPLETE, completeHandler); myTimer.start(); private function timerHandler(e:TimerEvent):void { repeat--; statusTextField.text = ((delay * repeat) / 1000) + " seconds left."; }; private function completeHandler(e:TimerEvent):void { statusTextField.text = "Times Up."; inputTextField.type = TextFieldType.DYNAMIC; };