Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    May 2007
    Posts
    130
    Thanks
    9
    Thanked 0 Times in 0 Posts

    How would I relate a variable to an object?

    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?


    Code:
    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.
    Last edited by lpeek; 06-30-2009 at 03:49 PM.

  • #2
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    button should be the instance name of the movieclip (not a button!), do you have that?
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •