I need an action script code to play a timer. I can pause it, but I can't resume it. Help me out!
The code I used for Timer:
var time:Number = 0;
function updateMinutes() {
time++;
timer.text=time;
/*timer is the instance name of dynamic text which shows the counting in second.*/
}
timeInterval=setInterval(updateMinutes, 1000);
And for pause:
on (release) {
timer=pause();
}
And for resume:
Need the code
pause/resume timer
- asifshahid
- Insanely Distorted

- Posts: 4329
- Joined: Tue Oct 16, 2007 2:35 pm
- Full Name: Asif Shahid
- x 37
- zahidur59
- Posts: 128
- Joined: Sun Oct 21, 2007 4:49 pm
- Full Name: Khandakar Zahidur Rahaman
- Expertise: Jack of all, master of NONE
put this on the first frame of root timeline
Assuming the pause and resume buttons have the instance names _pause and _resume, respectively,
for _pause button -
for _resume button -
Note that this is not accurate. You will loose the fractions of the second passed just before the Pause button was clicked. For a precise one, study some on getTimer() function.
Oh and the pause() used in your code is for a totally different purpose. DON'T confuse it with this scenario.
Code: Select all
var time:Number = 0;
function updateMinutes() {
var time = Number(timer.text);
time++;
timer.text=time;
/*timer is the instance name of dynamic text which shows the counting in second.*/
}
var timeInterval = setInterval(updateMinutes, 1000);
_resume.enabled = false;
_pause.enabled = true;for _pause button -
Code: Select all
on (release) {
clearInterval(timeInterval);
_resume.enabled = true;
_pause.enabled = false;
}Code: Select all
on (release) {
_root.timeInterval = setInterval(updateMinutes, 1000);
_resume.enabled = false;
_pause.enabled = true;
}Oh and the pause() used in your code is for a totally different purpose. DON'T confuse it with this scenario.
- asifshahid
- Insanely Distorted

- Posts: 4329
- Joined: Tue Oct 16, 2007 2:35 pm
- Full Name: Asif Shahid
- x 37
wwooooooooowwww, it's working!!!!!!.......many many thanks Zahid Bhai.....ya it takes less than a second when i press the resume button.....but for now my project don't mind that
....If I get anything about getTimer() I will post here. Thanks again.