Search code examples
actionscriptmouseinvisibleoutanimated

ActionScript 3 Mouse Out


I'm creating an animated (in and out) drop down menu. I've managed to get the menu to open when the user mouses over, with the buttons all selectable. However I can't seem to find an efficient method of making the drop down menu close whenever the mouse is not over the menu.

Actions:

Nav_Main_Sports.addEventListener(MouseEvent.MOUSE_OVER, Nav_Main_Sports_Open);
Nav_Main_Sports_Out.addEventListener(Event.MOUSE_LEAVE, Nav_Main_Sports_Close);

function Nav_Main_Sports_Open(event:MouseEvent):void
{
    gotoAndPlay(2);
}

function Nav_Main_Sports_Close(event:MouseEvent):void
{
    gotoAndPlay(14);
}

Stops are included, but on a separate layer.

All help would be appreciated. Thanks in advanced.


Solution

  • Actions:

    Nav_Main_Sports.addEventListener(MouseEvent.ROLL_OVER, Nav_Main_Sports_Open);
    Nav_Main_Sports.addEventListener(MouseEvent.ROLL_OUT, Nav_Main_Sports_Close);
    
    function Nav_Main_Sports_Open(event:MouseEvent):void
    {
        Nav_Main_Sports.gotoAndPlay(2);
    }
    
    function Nav_Main_Sports_Close(event:MouseEvent):void
    {
        Nav_Main_Sports.gotoAndPlay(14);
    }
    

    Worked out the best method for this, use ROLL_OVER and ROLL_OUT and refer to the drop down menu in the function. This worked perfectly for me.