AS3 如何在目标 mc 的 MouseOut 上重置 Tween?
AS3 How to Reset A Tween on MouseOut of target mc?
在这个例子中,我有 3 个面板,在一个名为 "panelHolder" 的 mc 中。
目标:当鼠标悬停在目标 mc 扩展上时,能够仅将 "bgr" mc (panelHolder.panel1.Bgr) 中的 bgr 颜色补间为不同的颜色,然后当鼠标悬停在其他目标 mc 之一上时重置(也应该 运行 相同的动画)?
这是我的代码:
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();
感谢任何意见!
如果我对问题的理解正确,你只想在 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}});
}
为了向选项卡区域添加颜色补间,我这样做了:
在 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}});
}
在这个例子中,我有 3 个面板,在一个名为 "panelHolder" 的 mc 中。
目标:当鼠标悬停在目标 mc 扩展上时,能够仅将 "bgr" mc (panelHolder.panel1.Bgr) 中的 bgr 颜色补间为不同的颜色,然后当鼠标悬停在其他目标 mc 之一上时重置(也应该 运行 相同的动画)?
这是我的代码:
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();
感谢任何意见!
如果我对问题的理解正确,你只想在 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}});
}
为了向选项卡区域添加颜色补间,我这样做了: 在 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}});
}