PDA

View Full Version : countdown 5 to 0


ewor
05-05-2010, 11:27 AM
i have been asked to make a countdown from 5 to 0 within 10seconds using flash and i have no idea where 2 start can somone help me with the code
thank you

Noct
05-05-2010, 01:40 PM
Welcome aboard, give this a try:

//Create TextField
var timeText:TextField = this.createTextField("timeText", this.getNextHighestDepth(), 100, 100, 100, 100);
//Set intial time
timeText.text = "5";
//Set variable to time
var timeNum:Number = 5;
//Create interval at 2 seconds (2*5=10 seconds)
var timeInc:Number = setInterval(incTimer, 2000);
//Call function on interval
function incTimer():Void {
//If number is greater then 0 - drop the number by one, else - clear the interval
(timeNum>0) ? timeNum-- : clearInterval(timeInc);
//Send the new number to the textfield
timeText.text = String(timeNum);
}

ewor
05-12-2010, 12:38 PM
omg thank you :p