Copy link to clipboard
Copied
i need a help ! how to solve in this error
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at RECOVER_assignment1_crossword_fla::MainTimeline/Play()[RECOVER_assignment1_crossword_fla.MainTimeline::frame3:11]
here is my code:
import flash.events.Event;
stop();
var score: int = 0;
var correctInc: int = 10;
score_txt_.text=score.toString();
stage.addEventListener(Event.ENTER_FRAME, Play);
function Play(e:Event) :void {
if (emotional_e_txt.text == ("E").toString() &&
emotional_m_txt.text == ("M").toString() &&
emotional_o_txt.text == ("O").toString() &&
emotional_t_txt.text == ("T").toString() &&
emotional_i_txt.text == ("I").toString() &&
emotional_o1_txt.text == ("O").toString() &&
emotional_n_txt.text == ("N").toString() &&
emotional_a_txt.text == ("A").toString() &&
emotional_l_txt.text == ("L").toString()) {
emobox_mc.gotoAndStop(3);
score = correctInc;
} else if(emotional_e_txt.text == ("").toString() &&
emotional_m_txt.text == ("").toString() &&
emotional_o_txt.text == ("").toString() &&
emotional_t_txt.text == ("").toString() &&
emotional_i_txt.text == ("").toString() &&
emotional_o1_txt.text == ("").toString() &&
emotional_n_txt.text == ("").toString() &&
emotional_a_txt.text == ("").toString() &&
emotional_l_txt.text == ("").toString()){
emobox_mc.gotoAndStop(1);
} else {
emobox_mc.gotoAndStop(2);
}
if (depresion_d_txt.text == ("D").toString() &&
depresion_p_txt.text == ("P").toString() &&
depresion_r_txt.text == ("R").toString() &&
depresion_e_txt.text == ("E").toString() &&
depresion_s_txt.text == ("S").toString() &&
depresion_i_txt.text == ("I").toString() &&
depresion_o_txt.text == ("O").toString() &&
depresion_n_txt.text == ("N").toString()) {
depbox_mc.gotoAndStop(3);
score += correctInc;
} else if (depresion_d_txt.text == ("").toString() &&
depresion_p_txt.text == ("").toString() &&
depresion_r_txt.text == ("").toString() &&
depresion_e_txt.text == ("").toString() &&
depresion_s_txt.text == ("").toString() &&
depresion_i_txt.text == ("").toString() &&
depresion_o_txt.text == ("").toString() &&
depresion_n_txt.text == ("").toString()) {
depbox_mc.gotoAndStop(1);
} else {
depbox_mc.gotoAndStop(2);
}
if (fatigue_f_txt.text == ("F").toString() &&
fatigue_i_txt.text == ("I").toString() &&
fatigue_t_txt.text == ("T").toString() &&
fatigue_g_txt.text == ("G").toString() &&
fatigue_u_txt.text == ("U").toString() &&
fatigue_e_txt.text == ("E").toString()) {
fatbox_mc.gotoAndStop(3);
score += correctInc;
} else if (fatigue_f_txt.text == ("").toString() &&
fatigue_t_txt.text == ("").toString() &&
fatigue_i_txt.text == ("").toString() &&
fatigue_g_txt.text == ("").toString() &&
fatigue_u_txt.text == ("").toString() &&
fatigue_e_txt.text == ("").toString()) {
fatbox_mc.gotoAndStop(1);
} else {
fatbox_mc.gotoAndStop(2);
}
if (medication_m_txt.text == ("M").toString() &&
medication_e_txt.text == ("E").toString() &&
medication_d_txt.text == ("D").toString() &&
medication_c_txt.text == ("C").toString() &&
medication_a_txt.text == ("A").toString() &&
medication_t_txt.text == ("T").toString() &&
medication_i_txt.text == ("I").toString() &&
medication_o_txt.text == ("O").toString() &&
medication_n_txt.text == ("N").toString()) {
medbox_mc.gotoAndStop(3);
score += correctInc;
} else if (medication_m_txt.text == ("").toString() &&
medication_e_txt.text == ("").toString() &&
medication_d_txt.text == ("").toString() &&
medication_c_txt.text == ("").toString() &&
medication_a_txt.text == ("").toString() &&
medication_t_txt.text == ("").toString() &&
medication_i_txt.text == ("").toString() &&
medication_o_txt.text == ("").toString() &&
medication_n_txt.text == ("").toString()) {
medbox_mc.gotoAndStop(1);
} else {
medbox_mc.gotoAndStop(2);
}
if (physical_p_txt.text == ("P").toString() &&
physical_h_txt.text == ("H").toString() &&
physical_y_txt.text == ("Y").toString() &&
physical_s_txt.text == ("S").toString() &&
physical_c_txt.text == ("C").toString() &&
physical_a_txt.text == ("A").toString() &&
physical_l_txt.text == ("L").toString()) {
phybox_mc.gotoAndStop(3);
score += correctInc;
} else if (physical_p_txt.text == ("").toString() &&
physical_h_txt.text == ("").toString() &&
physical_y_txt.text == ("").toString() &&
physical_s_txt.text == ("").toString() &&
physical_c_txt.text == ("").toString() &&
physical_a_txt.text == ("").toString() &&
physical_l_txt.text == ("").toString()) {
phybox_mc.gotoAndStop(1);
} else {
phybox_mc.gotoAndStop(2);
}
score_txt_.text=score.toString();
}
done_btn.addEventListener(MouseEvent.CLICK, goNext);
function goNext(event:MouseEvent):void
{
gotoAndStop(4);
}
i hope someone can help me. Thank you
Copy link to clipboard
Copied
Hi.
My best guess is that when you go to another frame in the main timeline, some instance becomes inaccessible because the enterFrame event continues firing. You should remove it before navigating away from the current frame.
Please let us know.
Regards,
JC
Copy link to clipboard
Copied
and you should learn bracket notation to condense and make your code easier to read and debug.