如果不同的影片剪辑触发了鼠标悬停事件,如何更改一个影片剪辑的 Alpha

发布于 2024-10-18 03:49:00 字数 714 浏览 1 评论 0原文

我有一个影片剪辑(出于识别目的,我们将其称为 mc_A),它在鼠标悬停事件时向下滚动,并在鼠标移出事件时向上滚动。我有一个单独的影片剪辑 (mc_B),我希望在卷起 mc_A 时使其不可见。然后在触发 mc_A 的鼠标悬停事件时淡入。

这是我到目前为止的代码,即鼠标悬停时按钮“自行向下滑动”的代码。

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});
} 

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});
} 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

三生一梦 2024-10-25 03:49:00

像这样的东西。我假设在下面的代码中 menu_mc 是您所指的 mc_a 。

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});
}

另外,不确定你在用这条线做什么:

light_mc.addEventListener(MouseEvent.

但这并不完整。也许只是一个糟糕的复制和粘贴?

如果您将变量实例化更改为:

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

那么您可以调整菜单的位置,并且仍然让它下降相同的距离,而无需再次调整visible_menu变量。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文