FORUMS: list search recent posts

problem with button in AS3

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Zach Gold
problem with button in AS3
on Apr 5, 2009 at 6:00:20 pm

Hi All,

I'm new to Flash and just trying to make a button link in AS3 (using Flash Authoring tool CS3). At first I thought the problem was the change in syntax from AS2, but that doesn't seem to be the case. I created a new layer for actions and put this code in frame one, where myButton was a rectangle converted into a button symbol:

myButton.addEventListener(MouseEvent.CLICK, myClick);
function myClick(event:MouseEvent):void {
trace("I've been clicked!");

I get the error: "1120: Access of undefined property myButton." Any ideas what I'm doing wrong?


Return to posts index

Pieter Helsen
Re: problem with button in AS3
on Apr 5, 2009 at 7:27:57 pm

You didn't give the button an instance name (Window > Properties).

Kind regards,

General notice: from now on, I would like to ask everyone to put [AS2] or [AS3] (corresponding to the version of actionscript you are using on your project) in front of their post titles when the question is actionscript related! Please help us help you faster. Thank you.

Return to posts index

Zach Gold
Re: problem with button in AS3
on Apr 5, 2009 at 8:04:11 pm

Thanks! I thought I had done that by naming it in the library window, but I realize now I could create multiple instances of that button.

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 All Rights Reserved