/ Published in: ActionScript 3
Code generates a Textfield and counts down from 20 to 0.
Just paste code into an empty FLA-File on the first frame.
Just paste code into an empty FLA-File on the first frame.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
var i:Number = 20; var myTimer:Timer = new Timer(1000); myTimer.addEventListener(TimerEvent.TIMER, countDown); var myTextField:TextField = new TextField(); myTextField.autoSize = TextFieldAutoSize.LEFT; addChild(myTextField); var format:TextFormat = new TextFormat(); format.font = "Verdana"; format.color = "0xFF0000"; format.size = 10; myTextField.defaultTextFormat = format; function countDown(evt:TimerEvent) { trace("new Time: "+i); --i == -1 ? myTimer.reset() : myTextField.text = new String(i); } myTimer.start();