Forum Moderators: open
Flash newb here. I will really appreciate any help that can be given.
So I have four buttons that I created in flash. I used the primitive rectangle tool and created a rectangle. I converted it to a symbol of type button. I gave the button an instance name. I then create 3 more using the same procedure and gave them all unique instance names.
I want to add an event listener to the button. I followed the technique used in a tutorial and it works in the tutorial and not for me.
Here is a code snippet:
*****************
home_button.addEventListener(MouseEvent.MOUSE_OVER,runHomeButton);
gallery_button.addEventListener(MouseEvent.MOUSE_OVER,runGalleryButton);
press_button.addEventListener(MouseEvent.MOUSE_OVER,runPressButton);
contact_button.addEventListener(MouseEvent.MOUSE_OVER,runContactButton);
function runHomeButton(e:MouseEvent):void {
home_popup.visible = true;
home_popup.play();
}
function runGalleryButton(e:MouseEvent):void {
gallery_popup.visible = true;
gallery_popup.play();
}
function runPressButton(e:MouseEvent):void {
press_popup.visible = true;
press_popup.play();
}
function runContactButton(e:MouseEvent):void {
contact_popup.visible = true;
contact_popup.play();
}
*****************
Now when this runs I get the error of:
*****************
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at flash_skin_fla::MainTimeline/flash_skin_fla::frame1()
*****************
I know that it is the code that is trying to put the assign the event listener because when I remove that block then it works fine. When i add even one of the lines back in it errors again.
Anyone have any insight as to why? The code is identical to the example I followed.