Timer Error

Hey there,

I am creating a game, and have a problem with one of the functions. I have created a function to count to 6 and move to the next frame. The ode looks like this:

var countTimer= new Timer (1000, 6);
countTimer.start();
countTimer.addEventListener(TimerEvent.TIMER, countdown);

function countdown (time:TimerEvent):void
{
tellTimeBox_txt.text = String(6 - time.target.currentCount);
trace(time.target.currentCount);
if ((6 - time.target.currentCount) == 0)
{
this.nextFrame();
removeEventListener(Event.ENTER_FRAME, onEnterFrame1);
myTimer.stop();
myTimer.removeEventListener(TimerEvent.TIMER, countdown);

}

}

On the next frame there is a button saying “Restart Game”. If you click on it, it brings you back to frame one where the timer starts counting again.

The following error is appearing when the counter counts to 6.

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at humanrescuegame_fla::MainTimeline/countdown()
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()

Any ideas on where I’m going wrong?