Search code examples
flashactionscript-3buttonadobenavigation

How to change one movieclip's alpha if a different movieclip has triggered a mouse over event


I have a movie clip (let's call it mc_A for identification purposes) that rolls down on a mouse over event and rolls back up on a mouse out event. I have a separate movie clip (mc_B) that I want to make invisible when mc_A is rolled up. Then fade in when mc_A's mouse over event is triggered.

This is the code I have so far, that is, as far as the button 'sliding itself down' on mouse over.

import com.greensock.*;
import com.greensock.easing.*;

/************** Slide Menu **************/
var invisible_menu : Number = menu_mc.y;
var visible_menu : Number = 12;

menu_mc.addEventListener(MouseEvent.ROLL_OVER,showMenu);
menu_mc.addEventListener(MouseEvent.ROLL_OUT,hideMenu);

function showMenu(event:MouseEvent) :void{
    TweenLite.to(menu_mc, .15, {y:visible_menu,ease:Linear.easeNone});
}

function hideMenu(event:MouseEvent):void {
    TweenLite.to(menu_mc, .15, {y:invisible_menu,ease:Linear.easeNone});
} 

Solution

  • Something like this. I am presuming in the code below that menu_mc is the mc_a you are referring to.

    function showMenu(event:MouseEvent) :void
    {
        TweenLite.to(mc_b, .15, {alpha:1,ease:Linear.easeNone});
        TweenLite.to(menu_mc, .15, {y:visible_menu,ease:Linear.easeNone});
    }
    
    
    function hideMenu(event:MouseEvent):void
    {
        TweenLite.to(mc_b, .15, {alpha:0,ease:Linear.easeNone});
        TweenLite.to(menu_mc, .15, {y:invisible_menu,ease:Linear.easeNone});
    }
    

    also, not sure what you're doing with the line:

    light_mc.addEventListener(MouseEvent.
    

    but that is incomplete. Perhaps just a bad copy and paste?

    and if you change your variable instantiation to:

    var invisible_menu : Number = menu_mc.y;
    var visible_menu : Number = invisible_menu + 12;
    

    then you can adjust the location of your menu and still have it drop down the same distance without having to adjust the visible_menu variable again.