# Problems adding a timer to my game

**URL:** <https://forum.kirupa.com/t/problems-adding-a-timer-to-my-game/203154>\
**Category:** Uncategorized\
**Created:** [October 8, 2006, 1:00pm UTC](https://forum.kirupa.com/t/problems-adding-a-timer-to-my-game/203154 "2006-10-08T13:00:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![roguebot](https://avatars.discourse-cdn.com/v4/letter/r/7ab992/32.png) [@roguebot](https://forum.kirupa.com/u/roguebot)\
**Post date:** [October 8, 2006, 1:00pm UTC](https://forum.kirupa.com/t/problems-adding-a-timer-to-my-game/203154/1 "2006-10-08T13:00:17Z")

</div>

Hi I’m new to this forum so please bear with me if I over/under explain the situation.

I’ve been trying to make my own flash game based on the kirupa tutorial: [http://www.kirupa.com/developer/actionscript/vertical\_shooter.htm](http://www.kirupa.com/forum/../developer/actionscript/vertical_shooter.htm)

My scripting is very similar to the scripting in the tutorial, but I obviously adapted it to my own design. Now I’m trying to add a time limit, which when the time reaches 0 it jumps to the time up screen. I have spent two whole days searching on google, trying loads of suggestions, trying to figure this out myself. This is what I came up with:

//timer  
function timer(timeline) {  
seconds = 3;  
initial = getTimer()/1000;  
timeline.onEnterFrame = function() {  
var timeleft = Math.ceil(seconds-(getTimer()/1000-initial));  
\_root.time.text = timeleft\<10 ? “0”+timeleft : timeleft;

if (timeleft\<0) {  
delete this.onEnterFrame;  
gotoAndPlay(3);  
answer(0);  
}  
}  
};  
timer (\_root) ;

This scripting works on a test page (i.e. away from the actual game) but when I try to add it to my game it deletes the main movieclip (in this case a tank) which is used to play the game.

Check out the beta version of the game that I want to add the time limit too: [http://www.roguebot.co.uk/roguebotwars.html](http://www.roguebot.co.uk/roguebotwars.html)

[FONT=Arial]Any help would be greatly appreciated[/FONT][FONT=Arial][URL=“[http://www.kirupa.com/forum/../developer/actionscript/vertical\_shooter.htm](http://www.kirupa.com/forum/../developer/actionscript/vertical_shooter.htm)”][/FONT]
