var speed:Number = 1000;
var timer:Timer = new Timer(speed, 20);
timer.addEventListener(TimerEvent.TIMER, countdown);
timer.start();
function countdown(event:TimerEvent) {
var totalSecondsLeft:Number = 20 - timer.currentCount;
myText.text = timeFormat(totalSecondsLeft);
}
function timeFormat(seconds:int):String {
var sSeconds:String;
if (seconds == 0) {
resettimer();
}
if (seconds > 21) {
sSeconds = String(seconds % 60);
} else {
sSeconds = String(seconds);
}
if (sSeconds.length == 1) {
sSeconds = "0" + sSeconds;
}
return ":" + sSeconds;
}
function resettimer() {
nextFrame();
}
function moveOn() {
}