i made timer for my game, and code is
var countDownIncLvl2:Number=1;
var totalSecsLvl2 = 60;
var countDownSecsLvl2 = totalSecsLvl2;
counterLvl2.text=countDownSecsLvl2;
var timeLvl2:Timer = new Timer(countDownIncLvl2*1000);
time.addEventListener(TimerEvent.TIMER,tickLvl2);
function tickLvl2(e:TimerEvent):void {
if (countDownSecsLvl2 == 0){
trace(“count down complete”);
time.stop();
countDownSecsLvl2 = totalSecsLvl2;gotoAndPlay(1);}
else {
countDownSecsLvl2= countDownSecsLvl2-countDownIncLvl2;
counterLvl2.text=countDownSecsLvl2;
}
}
if(time.running == true) {
trace("alredy running");
} else {
counterLvl2.text=totalSecsLvl2;
time.start();
}
but it keeps showing me error in output as:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at proba1_fla::MainTimeline/tickLvl2()
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()
please somebody help :puzzled: