# Timer trouble!

**URL:** <https://forum.kirupa.com/t/timer-trouble/288133>\
**Category:** flash\
**Created:** [May 11, 2009, 6:23pm UTC](https://forum.kirupa.com/t/timer-trouble/288133 "2009-05-11T18:23:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![leptons](https://avatars.discourse-cdn.com/v4/letter/l/977dab/32.png) [@leptons](https://forum.kirupa.com/u/leptons)\
**Post date:** [May 11, 2009, 6:23pm UTC](https://forum.kirupa.com/t/timer-trouble/288133/1 "2009-05-11T18:23:58Z")

</div>

In a game I’m creating, the only last part I have left is to create a timer.  
Or a countdown to be precise.  
But I get thrown an error when I go to the next frame when the timer is finished.

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

```

There must be a way that works so that flash will “gotoAndStop(2);” after 3 minutes?  
Please help me 🙂

```auto
//Timer
var countDown:Timer = new Timer(10, 179);
var minutes:Number = 02;
var seconds:Number = 59;
var countExecute:Number = 03;
countDown.start();

countDown.addEventListener(TimerEvent.TIMER, countDownFunction);

function countDownFunction(event:TimerEvent):void {
	seconds--;
	
	if (seconds < 00){
		seconds = 59
		minutes--;
		countExecute--;
		trace(countExecute);
	}
	
	if (countExecute == 1) {
		gotoAndStop();
	}
	
	var showTime:String = minutes + ":" + seconds;
	timer_txt.text = showTime;
}

```
