我在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();
发布于 2011-02-25 07:01:03
我认为最简单的方法是使用"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);
}
这能满足你的需求吗?否则,您可以用一个新的补间替换补间,每次都传入补间的"begin“参数中的当前坐标,但我发现只使用"continueTo()”要简单得多,也更简洁。
https://stackoverflow.com/questions/5110629
复制相似问题