Problems adding a timer to my game

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:

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:

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;
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:

[FONT=Arial]Any help would be greatly appreciated[/FONT][FONT=Arial][URL=“”][/FONT]