'i have a type error #1009 on my coding and i don't know how to locate it
I am creating a quiz game but when I test run my game, this error pops up
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at issitokay_fla::MainTimeline/frame6()[issitokay_fla.MainTimeline::frame6:1]
at flash.display::MovieClip/gotoAndStop()
at Function/<anonymous>()[issitokay_fla.MainTimeline::frame5:8]
for context, this is my coding on frame 6
okay2_btn.addEventListener(MouseEvent.CLICK, right_ans3('1.4'));
notOkay2_btn.addEventListener(MouseEvent.CLICK, wrong_ans3('1.4'));
score_cnt.text=arnab.toString();
//quiz func
function right_ans3(next_question:String):Function{
return function (e:MouseEvent): void{
arnab++;
gotoAndStop(next_question);
}
}
function wrong_ans3(next_question:String):Function{
return function(e:MouseEvent): void {
gotoAndStop(next_question);
}
}
and this is my coding on frame 5
okay2_btn.addEventListener(MouseEvent.CLICK, right_ans2('1.3'));
notOkay2_btn.addEventListener(MouseEvent.CLICK, wrong_ans2('1.3'));
score_cnt.text=arnab.toString();
//quiz func
function right_ans2(next_question:String):Function{
return function (e:MouseEvent): void{
arnab++;
gotoAndStop(next_question);
}
}
function wrong_ans2(next_question:String):Function{
return function(e:MouseEvent): void {
gotoAndStop(next_question);
}
}
they are just basically the same. I tried to do the same code as above but with different functions, but it works well. I tried to search for a solution, but I do not understand how it works. can anyone lighten me?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
