【问题标题】:Easing smooth using AS3.0使用 AS3.0 轻松平滑
【发布时间】:2015-01-21 17:00:30
【问题描述】:

我想知道当鼠标悬停在使用 AS3.0 的对象时,是否有一种方法可以减轻缩放效果。我知道你可以使用影片剪辑来做到这一点,但我只想使用 AS3.0 来使我的文件尽可能紧凑!

我现在使用的代码很简单。

import flash.events.MouseEvent;

my_mc.addEventListener(MouseEvent.MOUSE_OVER, mouse_over);
my_mc.addEventListener(MouseEvent.MOUSE_OUT, mouse_out);

function mouse_over(evt:MouseEvent){
    my_mc.width = 200;
    my_mc.height = 200;
}

function mouse_out(evt:MouseEvent){
    my_mc.width = 90;
    my_mc.height = 90;
}

【问题讨论】:

    标签: actionscript-3 flash actionscript


    【解决方案1】:

    使用补间。我建议你看看TweenLite。您的代码如下所示:

    function mouse_over(evt:MouseEvent){
        TweenLite.to(my_mc, {width:200, height:200, ease:Cubic.easeInOut});
    }
    
    function mouse_out(evt:MouseEvent){
        TweenLite.to(my_mc, {width:90, height:90, ease:Cubic.easeInOut});
    }
    

    【讨论】:

    • 您可能想要实际指定一些缓动(因为这就是问题的真正意义所在)。我不记得 tween lite 默认是什么,但它可能是线性的。 Quad.easeInOutQuint.easeInOut 可能看起来不错。另外,解释一下TweenLite 不是免费的*也很好。如果您在向最终用户收取费用的应用程序中使用它,您需要获得许可。然而,还有许多替代方案,包括内置的Tween 类(它也可以使文件大小减小一点)。 TweenLite 是最好和最成熟的(至少在我看来)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-14
    • 2013-03-20
    • 2020-03-01
    • 2013-07-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多