在 ActionScript 中,如何使某物移动到某处并移回?
也许使用 Tween 类?我尝试了easeOut。但是如果写2个Tween,第二个会覆盖第一个,所以我只能看到obj在第二个Tween方向移动,而不是第一个Tween方向。
我知道下面第二个补间的坐标不正确(因为所有坐标都应遵循定义的参考点),所以我需要找出徽标的宽度和高度。但现在没关系,因为它是用于测试目的。
import fl.transitions.Tween;
import fl.transitions.easing.*;
logo.visible = false;
addChild(logo);
circle.addEventListener(MouseEvent.CLICK, moveObj);
function moveObj(e:MouseEvent):void{
logo.visible = true;
var tweenRight:Tween = new Tween(logo,"x",None.easeOut, 100, 300, 2, true);
var tweenLeft:Tween = new Tween(logo,"x",None.easeOut, 300, 100, 2, true);
}
Using Tween class maybe? I tried the easeOut. But if will write 2 Tween, the 2nd one will overwrite the 1st one, so I only see the obj moving in the 2nd Tween direction, not the 1st Tween direction.
I know the coordinates for the 2nd Tween below is not correct (because all coordinates should follow the defined reference point), so I need to find out the logo's width and height. But is alright now because it is for testing purpose.
import fl.transitions.Tween;
import fl.transitions.easing.*;
logo.visible = false;
addChild(logo);
circle.addEventListener(MouseEvent.CLICK, moveObj);
function moveObj(e:MouseEvent):void{
logo.visible = true;
var tweenRight:Tween = new Tween(logo,"x",None.easeOut, 100, 300, 2, true);
var tweenLeft:Tween = new Tween(logo,"x",None.easeOut, 300, 100, 2, true);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您同时触发两个补间,因此您可以收听 motion finish 事件并在此时启动另一个补间:
You are firing the two tweens at the same time so you can for example listen to motion finish event and launch the other tween at this moment:
这两个事件同时发生,您需要将第二个事件推迟到第一个事件结束之后。
You have both these happening at the same time, you'll need to delay the second one till after the first ends.