AS3如何重置目标mc的MouseOut上的Tween?

时间:2015-01-29 17:20:18

标签: actionscript-3 flash greensock

在这个例子中,我有一个名为" panelHolder"的mc内的3个面板。

目标:只能在" bgr"中使用bgr颜色。当鼠标悬停在目标mc上时,mc(panelHolder.panel1.Bgr)补间为不同的颜色,然后当鼠标悬停在其他目标mcs之一(也应该运行相同的动画)时重置?

这是我的代码:

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

//设置初始状态

panelHolder.panel1.alpha = 0;
panelHolder.panel2.alpha = 0;
panelHolder.panel3.alpha = 0;

//启动开始动画

function init():void {
TweenLite.to(panelHolder.panel1, .5, {y:266, alpha:1, delay:0.4});
TweenLite.to(panelHolder.panel2, .5, {y:400, alpha:1, delay:0.6});
TweenLite.to(panelHolder.panel3, .5, {y:534, alpha:1, delay:0.8});
}

init();

panelHolder.panel1.props = {ty:266, by:516, ind:1};
panelHolder.panel2.props = {ty:400, by:650, ind:2};
panelHolder.panel3.props = {ty:534, by:784, ind:3};

panelHolder.panel1.addEventListener(MouseEvent.ROLL_OVER, onMouseOver);
panelHolder.panel2.addEventListener(MouseEvent.ROLL_OVER, onMouseOver);
panelHolder.panel3.addEventListener(MouseEvent.ROLL_OVER, onMouseOver);

function onMouseOver(e:MouseEvent):void
{
var mousedOver:MovieClip = MovieClip(e.target);
for(var i:int=0; i<panelHolder.numChildren; i++)
{
     var mc:MovieClip = MovieClip(panelHolder.getChildAt(i));


if(mc.props.ind <= mousedOver.props.ind)

{

TweenLite.to(mc, .5, {y:mc.props.ty});
}

//如果没有动画到底部

else {
TweenLite.to(mc, .5, {y:mc.props.by});
}
}
}
stop();

感谢您的任何意见!

2 个答案:

答案 0 :(得分:0)

如果我正确理解了问题,你只想在if / else中做补间色彩。

if(mc.props.ind <= mousedOver.props.ind)
{
    TweenLite.to(mc, .5, {y:mc.props.ty});
    TweenMax.to(mc, 1, {colorTransform:{tint:0x2ea0dd, tintAmount:1}}); 
{
else
}
    TweenLite.to(mc, .5, {y:mc.props.by});
    TweenMax.to(mc, 1, {colorTransform:{tint:0x2ea0dd, tintAmount:0}}); 
}

答案 1 :(得分:0)

为了将颜色补间添加到选项卡区域,我执行了以下操作: 在onMouseOver函数中,我添加了以下内容: 这将为背景选项卡颜色设置动画:

TweenMax.to(mousedOver.tab.bgrColor, .5, {colorTransform:{tint:0x2ea0dd, tintAmount:1}});

然后在if else语句中重置:

if(mc.props.ind != mousedOver.props.ind ){
    TweenMax.to(mc.tab.bgrColor, .5, {colorTransform:{tint:0x2ea0dd, tintAmount:0}});
    }