Return to Snippet

Revision: 13360
at April 21, 2009 10:26 by pfeisinger


Initial Code
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();

Initial URL


Initial Description
Code generates a Textfield and counts down from 20 to 0.
Just paste code into an empty FLA-File on the first frame.

Initial Title
Backwards Counting Timer

Initial Tags


Initial Language
ActionScript 3