# Countdown timer

**URL:** <https://forum.kirupa.com/t/countdown-timer/11889>\
**Category:** Uncategorized\
**Created:** [January 23, 2003, 6:10pm UTC](https://forum.kirupa.com/t/countdown-timer/11889 "2003-01-23T18:10:27Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![rhombusleech](https://avatars.discourse-cdn.com/v4/letter/r/a6a055/32.png) [@rhombusleech](https://forum.kirupa.com/u/rhombusleech)\
**Post date:** [January 23, 2003, 6:10pm UTC](https://forum.kirupa.com/t/countdown-timer/11889/1 "2003-01-23T18:10:27Z")

</div>

I’ve found a few tutorials on the web, but none of them have really worked for me. I know this is probably a really simple thing to do, but I just can’t figure it out. So I’ve come to the all-mighty kirupa forum for guidance.

Basically all I want is a 30 minute timer that counts down to zero, displaying the minutes and seconds as it counts down. When the timer reaches zero I want the movie to go to a specific frame label.

Thanks in advance, this forum rocks!

David

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [January 23, 2003, 6:26pm UTC](https://forum.kirupa.com/t/countdown-timer/11889/2 "2003-01-23T18:26:05Z")

</div>

Hey David,

We’re discussing this here:  
[http://www.kirupaforum.com/showthread.php?s=&threadid=13247](http://www.kirupaforum.com/showthread.php?s=&threadid=13247)

Maybe it’ll help.

- Lex

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [January 23, 2003, 6:33pm UTC](https://forum.kirupa.com/t/countdown-timer/11889/3 "2003-01-23T18:33:37Z")

</div>

on a movieclip this code should look something like this:

```auto

onClipEvent(load) {
deadline = getTimer()+30000;
}
onClipEvent(enterFrame) {
countdown = (deadline-getTimer);
mytextbox = countdown*1000;
if(countdown<0) {
<do something if the countdown reaches 0>
}
}

```

or on a 3-frame loop like this:  
on the first frame:

```auto
deadline = getTimer()+30000;

```

on the second frame:

```auto
countdown = (deadline-getTimer);
mytextbox = countdown*1000;
if(countdown<0) {
<do something if the countdown reaches 0>
}

```

on the third frame:

```auto
gotoAndPlay(2); 

```

-.-------.-

_deadline = getTimer()+30000;_ \<- this little piece of code calculates the deadline (the time when the countdown reaches 0)  
30minutes multiplied by 1000 is 30000 cuz it’s in milliseconds  
[SIZE=1]note: getTimer() returns the number of seconds that have elapsed since the movie was started not starts a timer[/SIZE]  
_countdown = (deadline-getTimer);_ \<-calculates how much time to deadline!  
mytextbox = countdown\*1000;[SIZE=1]_optional_[/SIZE] \<- if you want creat a textbox give it a variable name and change “mytextbox” to the variable name of the textbox and the minutes left will be displayed there!  
if(countdown\<0) {  
\<do something if the countdown reaches 0\>  
}  
if the countdown reaches zero the bomb explodes! just replace “\<do something…bla bla bla\>” with the actions you want it to trigger if the countdown reaches zero!

:):nerd:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [January 23, 2003, 6:34pm UTC](https://forum.kirupa.com/t/countdown-timer/11889/4 "2003-01-23T18:34:06Z")

</div>

thanks, I noticed that thread right after I started mine. it looks like you’ve figured out what i’m trying to do though. mine is really basic, just a countdown timer and when it reaches zero i want the movie to jump to a label. any help?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [January 23, 2003, 6:36pm UTC](https://forum.kirupa.com/t/countdown-timer/11889/5 "2003-01-23T18:36:59Z")

</div>

WOW, thanks syco!! I’ll give that code a try.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [January 23, 2003, 6:38pm UTC](https://forum.kirupa.com/t/countdown-timer/11889/6 "2003-01-23T18:38:44Z")

</div>

DOH’ DJ! I always do it the hardest way! 😛  
well rhombus the code DJ gave you the actions for this would be like this:  
if(display.text == 30) {  
\_root.yourmovieclip.gotoAndStop(“yourlabel”);  
}

replace yourmovieclip with the movieclip you want!  
also note that the counter counts up like 1, 2, ,3 not 3,2,1,0  
change ++myTimer to --myTimer!  
or you can do it with variables but hey…doesn’t matter! 😛

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [January 23, 2003, 6:50pm UTC](https://forum.kirupa.com/t/countdown-timer/11889/7 "2003-01-23T18:50:22Z")

</div>

ok i think i’m royally confused now.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [January 23, 2003, 7:09pm UTC](https://forum.kirupa.com/t/countdown-timer/11889/8 "2003-01-23T19:09:35Z")

</div>

ok i must be doing something wrong… i can’t get the code to work. maybe i’m not using it correctly…

display.text = myTimer = 0;  
showTimer = function(){  
display.text = --myTimer;  
}  
timerInterval = setInterval(showtimer,1000);

where do i place this? on a blank movie clip? in a frame in the timeline? and where is the timer displayed? in a dynamic text box named display?

David

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [January 24, 2003, 5:57pm UTC](https://forum.kirupa.com/t/countdown-timer/11889/9 "2003-01-24T17:57:23Z")

</div>

I’m not sure! Ask DJ! 🙂  
I think it shouldgo on a frame!
