homepage Welcome to WebmasterWorld Guest from 54.211.230.186
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Flash and Shockwave
Forum Library, Charter, Moderator: open

Flash and Shockwave Forum

    
Actionscript 3.0 debuggin question.
Need help understanding an error message.
Demaestro

WebmasterWorld Senior Member demaestro us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3376132 posted 7:23 pm on Jun 22, 2007 (gmt 0)

Hey all...

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.

 

Demaestro

WebmasterWorld Senior Member demaestro us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3376132 posted 7:59 pm on Jun 22, 2007 (gmt 0)

Sorry if you read this already..... I found that the buttons I am referencing in frame 1 aren't actually brought to the stage until a frame later on...... this is why it was a null object..... I copied them over to the first frame and it is working now.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Flash and Shockwave
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved