# Timer problem

**URL:** <https://forum.kirupa.com/t/timer-problem/190059>\
**Category:** Uncategorized\
**Created:** [June 8, 2006, 9:43am UTC](https://forum.kirupa.com/t/timer-problem/190059 "2006-06-08T09:43:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![animatedken](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/animatedken/32/2466_2.png) [@animatedken](https://forum.kirupa.com/u/animatedken)\
**Post date:** [June 8, 2006, 9:43am UTC](https://forum.kirupa.com/t/timer-problem/190059/1 "2006-06-08T09:43:37Z")

</div>

Hi!

I’m integrating a timer [based on a tutorial](http://www.spoono.com/flash/tutorials/tutorial.php?id=22).

This timer works very well and it’s basic code is as follows:

```auto

_root.onEnterFrame = function() {
	if (timing) {
		//calculate values
		elapsedTime = getTimer()-startTime;
		//hours
		elapsedHours = Math.floor(elapsedTime/3600000);
		remaining = elapsedTime-(elapsedHours*3600000);
		//minutes
		elapsedM = Math.floor(remaining/60000);
		remaining = remaining-(elapsedM*60000);
		//seconds
		elapsedS = Math.floor(remaining/1000);
		remaining = remaining-(elapsedS*1000);
		//hundredths
		elapsedH = Math.floor(remaining/10);
		//output to text box
		//add a 0 on the front of the numbers 
		//if the number is less than 10
		if (elapsedHours<10) {
			hours = "0"+elapsedHours.toString();
		} else {
			hours = elapsedHours.toString();
		}
		if (elapsedM<10) {
			minutes = "0"+elapsedM.toString();
		} else {
			minutes = elapsedM.toString();
		}
		if (elapsedS<10) {
			seconds = "0"+elapsedS.toString();
		} else {
			seconds = elapsedS.toString();
		}
		if (elapsedH<10) {
			hundredths = "0"+elapsedH.toString();
		} else {
			hundredths = elapsedH.toString();
		}
		_root.timer_txt = hours+":"+minutes+":"+seconds+":"+hundredths;
	}
};

```

The code is placed on frame 1 of a layer called “actions”. **The problem is when the movie goes to the next frame, the timer freezes** , likely because the 2nd frame does not have the actionscript to compute the time anymore.

Is there a way to make the timer continue counting even if the movie jumps to different frames (sort of like a global function)?

I’m certain I’m overlooking a simple solution to this and any assistance will be much appreciated. Thanks! 🍺
