# End Movie Timer

**URL:** <https://forum.kirupa.com/t/end-movie-timer/38739>\
**Category:** flash\
**Created:** [December 29, 2003, 7:49am UTC](https://forum.kirupa.com/t/end-movie-timer/38739 "2003-12-29T07:49:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![macneilslt](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@macneilslt](https://forum.kirupa.com/u/macneilslt)\
**Post date:** [December 29, 2003, 7:49am UTC](https://forum.kirupa.com/t/end-movie-timer/38739/1 "2003-12-29T07:49:44Z")

</div>

I’m trying to make a timer for a movie, so far i have AS like this on a MC that is playing…

[AS]

onClipEvent(enterFrame) {

```
     timer = getTimer()
     rtime = Math.round(timer/1000)
     _root.frameText.text = "Current Frame: " + _currentframe;
     _root.timebox.text = "Seconds elapsed: " + rtime;

```

}

[/AS]

What i want to know… How can i get the timer to stop counting when this mc gets to the last frame ? and restart when if it’s played over again.

---

<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:** [December 29, 2003, 9:14am UTC](https://forum.kirupa.com/t/end-movie-timer/38739/2 "2003-12-29T09:14:45Z")

</div>

well this fixes it so that it stops counting when it gets to the last frame.

For example if your last frame was 85 then you would use this  
[AS]  
onClipEvent(enterFrame) {  
if (\_currentframe \< 85) {  
timer = getTimer();  
rtime = Math.round(timer/1000);  
}  
\_root.frameText.text = "Current Frame: " + \_currentframe;  
\_root.timebox.text = "Seconds elapsed: " + rtime;

}  
[/AS]

I have no clue how to make it restart though…

---

<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:** [December 29, 2003, 9:18am UTC](https://forum.kirupa.com/t/end-movie-timer/38739/3 "2003-12-29T09:18:52Z")

</div>

Thanks DigiGamer, You’re my hero.

---

<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:** [December 29, 2003, 9:38am UTC](https://forum.kirupa.com/t/end-movie-timer/38739/4 "2003-12-29T09:38:41Z")

</div>

```auto

onClipEvent(enterFrame) {
        if (_currentframe < _totalframes) {
                timer = getTimer();
                rtime = Math.round(timer/1000);
        }
        _root.frameText.text = "Current Frame: " + _currentframe;
        _root.timebox.text = "Seconds elapsed: " + rtime;
        
}

```

im not a big fan of getTimer, but hey, whatever works. (i’d rather use setInterval).

---

<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:** [December 29, 2003, 9:41am UTC](https://forum.kirupa.com/t/end-movie-timer/38739/5 "2003-12-29T09:41:37Z")

</div>

thats what i have now, but how can i get it to restart when the MC restarts?

---

<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:** [December 29, 2003, 10:03am UTC](https://forum.kirupa.com/t/end-movie-timer/38739/6 "2003-12-29T10:03:10Z")

</div>

```auto
onClipEvent (load) {
	seconds = 0;
	function refreshTimer() {
		seconds++;
		if (_currentframe == _totalframes) {
			seconds = 0;
		}
		rtime = Math.round(seconds / 1000);
		_root.frameText.text = "Current Frame: " + _currentframe;
		_root.timebox.text = "Seconds elapsed: " + rtime;
	}
	timer = setInterval(refreshTimer, 1);
}

```

---

<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:** [December 29, 2003, 10:26pm UTC](https://forum.kirupa.com/t/end-movie-timer/38739/7 "2003-12-29T22:26:54Z")

</div>

did you test that?? doesn’t seem to work for me ☹
