-
[RESOLVED] Timer
I have a timer on the main timeline that triggers a function during a quiz that saves variables, scores the question and brings in the next question. At the end of the quiz in test mode I get an error that continually fires at the end of the quiz, but not during the quiz. Here is my timer.
PHP Code:
var count:Number=30;
var myTimer:Timer=new Timer(1000,count);
myTimer.addEventListener(TimerEvent.TIMER, countdown);
myTimer.start();
function countdown(event:TimerEvent):void {
question1_mc.myReflect_mc.timer_mc.myTimer_txt.text = String((count)-myTimer.currentCount);
question1_mc.myReflect_mc.MCreflect.myTimer_txt.text = String((count)-myTimer.currentCount);
if (question1_mc.myReflect_mc.timer_mc.myTimer_txt.text=="0") {
question1_mc.myReflect_mc.timer_mc.myTimer_txt.text="";
question1_mc.myReflect_mc.MCreflect.myTimer_txt.text="";
feedback_timer(event);
}
}
function resetCountDown():void {
if (myQuestions.length>1) {
myTimer.reset();
question1_mc.myReflect_mc.timer_mc.myTimer_txt.text=String(count);
question1_mc.myReflect_mc.MCreflect.myTimer_txt.text=String(count);
myTimer.start();
}
}
Here is the error message...I stop the timer in the feedback_timer function. The timer seems to work fine and the error doesn't seem to affect anything but I don't know why I'm getting it.
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at TEMPLATEQUIZvocschoolCS4_fla::MainTimeline/countdown()
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()
-
Which reference is null there?
Try also removing the timer event listener.
Post feedback_timer if that doesn't help.
-
Originally Posted by 5TonsOfFlax
Which reference is null there?
Try also removing the timer event listener.
Post feedback_timer if that doesn't help.
I removed the listener and that solved the problem. Thanks once again.
I think I know what was happening. I stopped the timer and advanced one frame where there was no timer on stage. Stopping the timer wasn't sufficient, I needed to remove the listener.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|