OK so all my code works fine on frame 1, but when I move it to frame 2, (keeping frame one blank with no MC’s or AS), i get the error "TypeError: Error #1009: Cannot access a property or method of a null object reference."
I have had this error before, and i know that it is to do with the scope of an object being incorrect, or that the object isn’t instantiated yet. I have identified the part of my code that is causing the problem through the debugger:
menuMC.homeBTN.addEventListener(MouseEvent.CLICK, changeContent);
I know this code is correct, as menuMC and homeBTN still have the same instance names, and are nested in the same way (nothing at all has been changed, just moved everything from frame 1 to frame 2). Im pretty sure this error can be fixed by moving menuMC to frame1 and setting its alpha to 0(whilst keeping it in frame 2), as the error is occurring due to the code being run prior to the MC/BTN loading. But what i can’t understand is why it works on frame 1 and not frame 2? And surely there is a better fix compared to what i just suggested…
Suggestions? (is it a bug in flash, or am i not understanding the logic?)