0

我已经在 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();
4

1 回答 1

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);
}

这能满足你的需求吗?否则,您可以用一个新的补间替换补间,每个在补间的“开始”参数中传入当前坐标,但我发现只使用“continueTo()”更容易和更清洁。

于 2011-02-24T23:01:03.373 回答