I am coding a flash game in which the ball hits a movie clip object and this takes the user to a new scene. I have 3 main methods: movePaddle, moveBall and changeFrame.
it works fine but when i execute the changeFrame method (ball hits movie clip)to go to a new frame i get a whole page of 1009 errors:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at FlashGameNEW_fla::MainTimeline/changeFrame()TypeError: Error #1009: Cannot access a property or method of a null object reference.
at FlashGameNEW_fla::MainTimeline/movePaddle()TypeError: Error #1009: Cannot access a property or method of a null object reference.
at FlashGameNEW_fla::MainTimeline/moveBall()
This is repeated many times.
Any help would be greatly appreciated. Thanks.
EDIT: with code below
function beginCode():void{
mcPaddle.addEventListener(Event.ENTER_FRAME, movePaddle);
mcBall.addEventListener(Event.ENTER_FRAME, moveBall);
mcBall.addEventListener(Event.ENTER_FRAME, changeFrame);
}
function movePaddle(event:Event):void{
mcPaddle.x = mouseX - mcPaddle.width / 2;
if(mouseX < mcPaddle.width / 2){
//Keep the paddle on stage
mcPaddle.x = 0;
}
if(mouseX > stage.stageWidth - mcPaddle.width / 2){
mcPaddle.x = stage.stageWidth - mcPaddle.width;
}
}
function changeFrame(event:Event):void{
if (mcBall.hitTestObject(Northcote)) {
this.gotoAndPlay(3);
}
}