AS3 Tween Easing

时间:2011-02-24 21:21:36

标签: actionscript-3 tween

我设置了一个悬停并将补间悬停在flash中的某个元素上,您将鼠标悬停在一个元素上,一个信息窗口从底部滑入,当您将其悬停时,它会向后滑动。悬停,当我在悬停动画结束前悬停时,给定对象跳转到第一个动画的结尾并返回。当某人盘旋在某物上时,如何让动画轻松进出?

function initialPlacement()
{
    block1.x = (-814);
    block1.y = (stage.stageHeight - 100);
}

initialPlacement();

tension.addEventListener(MouseEvent.ROLL_OVER,hover1);
tension.addEventListener(MouseEvent.ROLL_OUT,off1);

function hover1(event:MouseEvent):void{
    hover1tween.start();
}

var hover1tween:Tween = new Tween(block1,"x",Regular.easeOut,(0-block1.width),0,30,false);

hover1tween.stop();

function off1(event:MouseEvent):void{
    off1tween.start();
}

var off1tween:Tween = new Tween(block1,"x",Regular.easeInOut,0,(0-block1.width),30,false);
off1tween.stop();

initialPlacement();

1 个答案:

答案 0 :(得分:1)

我认为最简单的方法是使用“continueTo”函数,该函数将补间从新的方向发送,而不是重新启动它。

function initialPlacement()
{
    block1.x = (-814);
    block1.y = (stage.stageHeight - 100);

    block1tween = new Tween(block1,"x",Regular.easeInOut,(0-block1.width),0,30,false);
    block1tween.stop();
}

var block1tween:Tween;
initialPlacement();

tension.addEventListener(MouseEvent.ROLL_OVER,hover1);
tension.addEventListener(MouseEvent.ROLL_OUT,off1);

function hover1(event:MouseEvent):void{
    block1tween.continueTo(0, 30);
}

function off1(event:MouseEvent):void{
    block1tween.continueTo((0-block1.width),30);
}

这符合您的需求吗?否则你可以用一个新的替换补间,每个补丁都传递给Tween的“begin”参数中的当前坐标,但我发现只使用“continueTo()”更容易和更清洁。