[SIZE=2]Hey guys, I’m a newbie to flash/actionscript and need help making a countdown. I’m using actionscript 2.
This is the actionscript I’ve been using:
[/SIZE][SIZE=1]start_time = getTimer();
countdown = 30000;
onEnterFrame = function () {
elapsed_time = getTimer()-start_time;
_root.count.text = time_to_string(elapsed_time);
_root.count_down.text = time_to_string(_root.countdown-elapsed_time);
};
function time_to_string(time_to_convert) {
elapsed_hours = Math.floor(time_to_convert/3600000);
remaining = time_to_convert-(elapsed_hours3600000);
elapsed_minutes = Math.floor(remaining/60000);
remaining = remaining-(elapsed_minutes60000);
elapsed_seconds = Math.floor(remaining/1000);
remaining = remaining-(elapsed_seconds1000);
elapsed_fs = Math.floor(remaining/10);
if (elapsed_hours<10) {
hours = “0”+elapsed_hours.toString();
} else {
hours = elapsed_hours.toString();
}
if (elapsed_minutes<10) {
minutes = “0”+elapsed_minutes.toString();
} else {
minutes = elapsed_minutes.toString();
}
if (elapsed_seconds<10) {
seconds = “0”+elapsed_seconds.toString();
} else {
seconds = elapsed_seconds.toString();
}
if (elapsed_fs<10) {
hundredths = “0”+elapsed_fs.toString();
} else {
hundredths = elapsed_fs.toString();
}
return hours+":"+minutes+":"+seconds+":"+hundredths;
}
[/SIZE]*[SIZE=1][SIZE=2]I can’t seem to get it to stop at 0. It keeps going into negative numbers.
Also the more I add to it, I end up in errors or it doesn’t work, such as trying to have a moving background which is synced to a song.
And how can i add a play button which appears after it has counted down so i can go onto my game?[/SIZE][/SIZE]