I have these actions on Frame 1 which works fine…
//—handle events for buttons—\
mainMenu.addEventListener(MouseEvent.CLICK, clickSection);
systemOverview.addEventListener(MouseEvent.CLICK, clickSection);
trainingPatients.addEventListener(MouseEvent.CLICK, clickSection);
setupMaintenance.addEventListener(MouseEvent.CLICK, clickSection);
advancedConcepts.addEventListener(MouseEvent.CLICK, clickSection);
function clickSection(evtObj:MouseEvent) {
//—trace shows what’s happening in the output window—\
trace (“The “+evtObj.target.name+” button was clicked!”)
//—go to the section clicked on—\
gotoAndStop(evtObj.target.name);
}
The above Chapter buttons takes the user to frames 1, 2, 3, 4, or 5 where Sub-chapter buttons are located. The sub-chapter buttons take the user to the subchapters that are placed along the timeline (about 30 subchapters in total).
When the user clicks on the subchapter button, they land in the correct spot, but I get the following error…
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at AS_TEST_fla::MainTimeline/frame50()
at flash.display::MovieClip/gotoAndStop()
at AS_TEST_fla::MainTimeline/clickSystem()
The button on that frame (frame 50) is a new instance of the mainMenu button which was used on frame 1, but with new code (see below), which tells it to gotoAndStop on frame 2, but doesn’t work. Any thoughts on this?
//—Timeline change—\
mainMenu2.addEventListener(MouseEvent.CLICK, clickmainMenu2);
function clickmainMenu2(event:MouseEvent):void{
gotoAndStop(2);
}
Thanks!