View Full Version : How would I relate a variable to an object?

06-30-2009, 03:46 PM
Hey all,

I'm pretty new to AS so this may well be a stupid question...

How do I relate a variable to an object on the stage? I want to have a mouse over and a mouse out effect on a button yet when I use the code below I get the error:

ReferenceError: Error #1065: Variable button is not defined.

obviously the object on the stage is called 'button' but I didnt think I had to define objects as variables? I thought the below code was correct?

button.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
button.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);

function mouseOverHandler(e:MouseEvent):void
// the mouse over effect

function mouseOutHandler(e:MouseEvent):void
// the mouse out effect

Thanks for your help.

07-01-2009, 08:11 AM
button should be the instance name of the movieclip (not a button!), do you have that?