Standard error 1009/1010

Good morning/day/night (wherever you are :slight_smile:

I’ve got a problem with a website I’m designing on Flash. After trawling the internet, I can see it’s quite a common problem. But my knowledge of AS3 is pretty limited.

I have two scenes, enterPage and mainPage. enterPage has one button with the script:

stop();

enterBtn.addEventListener(MouseEvent.CLICK, enterB);
function enterB(event:MouseEvent):void{
	gotoAndPlay(1,"mainPage");
}

mainPage has the script:

stop();

var myMenuArray=[home,dinnerAtHome,activities,sights,sampleItinery,contact];
for each(var btn in myMenuArray){
	myMenuArray[btn].addEventListener(MouseEvent.CLICK,onBtnClick);
}
function onBtnClick(event:MouseEvent):void{
	pages.gotoAndStop(event.target.name);
	
}

The script on mainPage works perfectly when on it’s own, but when enterPage is run first it comes up with this stack trace:

TypeError: Error #1010: A term is undefined and has no properties.
at blahdiblah_fla::MainTimeline/frame2()
at flash.display::MovieClip/gotoAndPlay()
at blahdiblah_fla::MainTimeline/enterB()

and none of the buttons on mainPage work. I’ve tried playing around with it in small ways, and sometimes the error is 1009, but same problems.

I could restructure the entire website, but that would take quite a long time, considering there is a lot of information in the ‘pages’ movieclip on mainPage.

Does anyone know what I’m doing wrong? Without having to restructure the whole stage and timeline.