Null Object Reference Error

TypeError: Error #1009: Cannot access a property or method of a null object reference

I’m getting this error in a game I’m working on when all the levels have been completed and I go back to the main menu screen. There’s no problem at the very start of the game when it goes to this frame and the start button which the error is refering to is fully functional up until the point where I try to send the movie back to this frame. Any ideas on what the problem might be?

It’s a common problem. Your code is referring to a variable or an object which no longer exists, or maybe never existed in the first place. Or something outside the scope of your current function.

The error message should tell you which part of your code is causing offence.

You could run the debugger (DEBUG >>> DEBUG MOVIE) and when it hits a problem check the variables list. Something in that list will be null, even though you’re not expecting it to be null.

Difficult to be more specific without seeing your code.

stop();

startButton.addEventListener(MouseEvent.CLICK,clickStart);
function clickStart(event:MouseEvent) {
gotoAndStop(2);
}

That’s all there is to it in the frame I’m trying to get to. I know it’s a common error and usually I’m able to fix these basic things but I can’t see why the startButton wouldn’t exist the second time i went to this frame.

[EDIT]: I don’t know why the word “clickStart” looks separated but it it’s not when I try to edit it?