如何获得类似于链接中显示的弹簧效果(补间)

时间:2012-06-10 10:32:37

标签: actionscript actionscript-3

我看到this mouseover tween,我就是喜欢它。只需将鼠标悬停在拇指上即可看到弹簧效果。我知道专业人士可能很容易,但我不知道如何做到这一点。

对于任何可以建议我如何获得类似效果的人,我会非常感激,或者更好的是,建议我可以学习这个教程。

1 个答案:

答案 0 :(得分:2)

使用TweenLite。使用持续时间约为0.75的Bounce.easeOut 确保导入TweenLite

package
{
    import com.greensock.TweenLite;
    import com.greensock.easing.Bounce;

    import flash.display.Sprite;
    import flash.events.MouseEvent;

    public class Testerooni extends Sprite
    {
        public var ball:Sprite = new Sprite();
        public function Testerooni()
        {
            createBall();
            addChild(ball);
            ball.x = 100;
            ball.y = 100;
            ball.addEventListener(MouseEvent.MOUSE_OVER,bounceOver);
            ball.addEventListener(MouseEvent.MOUSE_OUT,bounceOut);
        }

        protected function bounceOver(e:MouseEvent):void
        {
            TweenLite.to(ball,0.5,{scaleX:2,scaleY:2,ease:Bounce.easeOut});
        }

        protected function bounceOut(e:MouseEvent):void
        {
            TweenLite.to(ball,0.5,{scaleX:1,scaleY:1,ease:Bounce.easeOut});
        }

        private function createBall():void
        {
            ball.graphics.lineStyle(1);
            ball.graphics.beginFill(0x0000FF,0.4);
            ball.graphics.drawCircle(0,0,15);
        }
    }
}