#1009: Cannot access a property or method of a null object reference.
Hello,
I have some issues in understanding y i get this error, here is my code for the menu btns of the site:
// handle events for menu btns
weDance_btn.addEventListener(MouseEvent.CLICK, clickWedance);
inFan_btn.addEventListener(MouseEvent.CLICK, clickInFan);
karnivale_btn.addEventListener(MouseEvent.CLICK, clickkarnivale);
outOfSpace_btn.addEventListener(MouseEvent.CLICK, clickoutOfSpace);
nightmare_btn.addEventListener(MouseEvent.CLICK, clickNightmare);
karnivale2_btn.addEventListener(MouseEvent.CLICK, clickKarnivale2);
bucharest_btn.addEventListener(MouseEvent.CLICK, clickBucharest);
function clickWedance(evtObj:MouseEvent) {
//trace shows what's happening .. in the output window
trace("The wedance btn was clicked!");
gotoAndStop("weDance");
}
function clickInFan(evtObj:MouseEvent) {
//trace shows what's happening .. in the output window
trace("The clubspace btn was clicked!");
gotoAndStop("inFan");
}
function clickkarnivale(evtObj:MouseEvent) {
//trace shows what's happening .. in the output window
trace("The kar btn was clicked!");
gotoAndStop("karnivale");
}
function clickoutOfSpace(evtObj:MouseEvent) {
//trace shows what's happening .. in the output window
trace("The outofspace btn was clicked!");
gotoAndStop("outOfSpace");
}
function clickNightmare(evtObj:MouseEvent) {
//trace shows what's happening .. in the output window
trace("The nightmare btn was clicked!");
gotoAndStop("Nightmare");
}
function clickKarnivale2(evtObj:MouseEvent) {
//trace shows what's happening .. in the output window
trace("The carnivale2 btn was clicked!");
gotoAndStop("karnivale2");
}
function clickBucharest(evtObj:MouseEvent) {
//trace shows what's happening .. in the output window
trace("The bucharest btn was clicked!");
gotoAndStop("bucharest");
}
it works with no errors!
But now i need to add another btn on the OutofSpace page and this is it:
spacePic_btn.addEventListener(MouseEvent.CLICK, clickSpacePic);
function clickSpacePic(evtObj:MouseEvent) {
//trace shows what's happening .. in the output window
trace("The SpacePic btn was clicked!");
gotoAndStop("SpacePics");
}
when i test movie in the output i get the error and the btn doesnt work.! Why?
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at WeDance_fla::MainTimeline/frame240()[WeDance_fla.MainTimeline::frame240:26] <<<< >>>> spacePic_btn.addEventListener(MouseEvent.CLICK, clickSpacePic);
at flash.display::MovieClip/gotoAndStop()
at WeDance_fla::MainTimeline/clickoutOfSpace()[WeDance_fla.MainTimeline::frame2:61] <<<<<>>>>> //trace shows what's happening .. in the output window
Note: i put the code for the spacePic_btn on the keyframe where outofspace page starts, it it counts
PLease help.
thank You!
