# Stopping countup timer on hitTest?

**URL:** <https://forum.kirupa.com/t/stopping-countup-timer-on-hittest/329255>\
**Category:** Uncategorized\
**Created:** [August 6, 2012, 10:08pm UTC](https://forum.kirupa.com/t/stopping-countup-timer-on-hittest/329255 "2012-08-06T22:08:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nibbler20293](https://avatars.discourse-cdn.com/v4/letter/n/c67d28/32.png) [@nibbler20293](https://forum.kirupa.com/u/nibbler20293)\
**Post date:** [August 6, 2012, 10:08pm UTC](https://forum.kirupa.com/t/stopping-countup-timer-on-hittest/329255/1 "2012-08-06T22:08:13Z")

</div>

Hey everyone,  
I am working on a project for school which involves developing a timer that counts up to accompany a small game.  
My idea involves the timer recording the amount of time taken to complete a small level, and then displaying the  
stopped time on the next frame as a final score.

This is the code I used for the countup timer (I am using AS2):

timer = 0;  
countup = function() {  
timer++;  
}

countupInterval = setInterval(countup,1000);

What I want to happen is for the counter to stop once the player reaches a certain object. The hitTest is already  
set up on the movie clip of the goal object, using this code (placed on the movie clip):

onClipEvent (enterFrame) {  
if (this.hitTest (\_root.player)) {  
\_root.gotoAndStop (2);  
}  
}

What I cant seem to be able to do is create code that will stop the timer once the player moves over the hitTest,  
allowing it to be displayed as a final score on the second frame. I have been researching on many forums and tutorial  
sites and have not yet found code so far that works for me in this situation. The project is due a week from now, if  
you guys could help me it would be much appreciated ! I can also provide any other additional details that may be needed.

p.s: I am using Flash CS5
