How to create a simple countdown with pause!

I’ve found numerous resources about getTimer() and stuff but I can’t get a grip on the function. I want to create a very simple countdown timer where the total time is 10min and when you press a button it starts counting down and if you press another button it pauses and if you click again resumes the countdown! Furthermore if not too complicated I want to show the seconds as well, for example 9min 40sec etc.

AS knowers help me out, please! :stuck_out_tongue:

here ya go :wink:

Appreciate it kax! There is a wierd thing with the timer! :frowning: When you press start it adds 59sec and then counts down! Also when it changes from 9:00 to 8:59 it first does 9:00->9:59->8:59!

Did you see the same?

:slight_smile:

what ?? i didn’t see that … i’ll download the file [size=1]i always delete the files after uploading them :P[/size] and check it out :slight_smile:

:stuck_out_tongue:

countdown = function () {
	ss > 0 ? ss -- : clearInterval(countdowni);
	s = ss%60;
	s < 10 ? s = "0"+s : null;
	s == 59 ? m -- : null;
	countdownBox.text = m+":"+s;
}

sorry :-\ … just replace the function and it should work fine now =)

np :stuck_out_tongue:

Originally posted by cookie
np :stuck_out_tongue:

np ? i should say np !!

you should say thanks !! :hair:

:stuck_out_tongue: j/k :wink:

sorry kax! Didn’t mean to be ungrateful! :frowning: THANK YOU THANKYOU THANKYOU! :stuck_out_tongue: :P:P

it’s ok. i was kidding :wink:

but … i like how it sounds :stuck_out_tongue:

you’re welcome =)

Is it correct to break up this code into 2 functions like this:

ctrl.onRelease = function() {
if (!counting) {
countdowni = setInterval(countdown, 1000);
this.nextFrame();
counting = true;
} else {
clearInterval(countdowni);
this.prevFrame();
counting = false;
}
};

start=function(){
if (!counting) {
countdowni = setInterval(countdown, 1000);
this.nextFrame();
counting = true;
}
}

pause=function(){
clearInterval(countdowni);
this.prevFrame();
counting = false;
}

kax??:stuck_out_tongue:

if it works … do whatever you want :wink:

but i doubt that your script would work … :-\

if you want to use the same mc to start/pause the countdown
you need the variable counting so the mc knows what to do everytime is clicked

if you use different buttons … one to start it and another to pause it
i guess you can use something like:

startcount = function() {
	countdowni = setInterval(countdown, 1000);
}
pausecount = function() {
	clearInterval(countdowni);
}
startctrl.onRelease = startcount;
pausectrl.onRelease = pausecount;

or

startctrl.onRelease = function() {
	countdowni = setInterval(countdown, 1000);
}
pausectrl.onRelease = function() {
	clearInterval(countdowni);
}

You’re hilarious kax! :stuck_out_tongue: :stuck_out_tongue: I’m being sarkastic!! Well like I said I’m no AS guru!:rambo:

you’re hilarious kax!

life is short … let’s make it fun :wink:

i’m being sarcastic!!

ok … don’t ever do that again :hair:

:stuck_out_tongue: jk :wink:

well like I said I’m no as guru!

me neither :-\

You’re right kax! Life is short! :stuck_out_tongue: =)
You should enjoy it will you can! Life without humour is boring! :stuck_out_tongue: :rambo:

believe me … i enjoy it :bad: :stuck_out_tongue: