End Movie Timer

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.

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…

Thanks DigiGamer, You’re my hero.


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).

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

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);
}

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