# Need help with countdown

**URL:** <https://forum.kirupa.com/t/need-help-with-countdown/326518>\
**Category:** flash\
**Created:** [December 20, 2011, 4:11pm UTC](https://forum.kirupa.com/t/need-help-with-countdown/326518 "2011-12-20T16:11:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![twinny1314](https://avatars.discourse-cdn.com/v4/letter/t/e9a140/32.png) [@twinny1314](https://forum.kirupa.com/u/twinny1314)\
**Post date:** [December 20, 2011, 4:11pm UTC](https://forum.kirupa.com/t/need-help-with-countdown/326518/1 "2011-12-20T16:11:20Z")

</div>

[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\_hours_3600000);  
elapsed\_minutes = Math.floor(remaining/60000);  
remaining = remaining-(elapsed\_minutes_60000);  
elapsed\_seconds = Math.floor(remaining/1000);  
remaining = remaining-(elapsed\_seconds_1000);  
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? ![](http://www.laymark.com/l/m/m075.gif)[/SIZE][/SIZE]
