ActionScript3 - 如何仅在Tween移动结束后删除

时间:2015-05-12 19:21:32

标签: actionscript-3

我希望此脚本中的最后一个语句UsedRange仅在Tween移动结束后执行。我怎么做?就在现在,它立即被删除。

removeChild(dropBall1);

2 个答案:

答案 0 :(得分:0)

您正在寻找的是使用TweenEvent课程。

基本上,使用TweenEvents,您可以在补间的生命周期中选择要执行的操作。值得注意的是,变量作用域成为侦听器的问题。自从我使用Tween和TweenEvent类以来已经有很长一段时间了,因此您可能需要重新构建事件处理函数以访问dropBall1变量,因为我不知道记住该功能是否可以访问它。

试试这个:

function onClick10f1(e:MouseEvent) {

    addChild(dropBall1);
    removeChild(bigBall1);
    dropBall1.x = 356.10;
    dropBall1.y = 28;
    var bigBDrop1:Tween = new Tween(dropBall1, "y", Regular.easeIn, 28, 156, 1, true);

    bigBDrop1.addEventListener(TweenEvent.MOTION_FINISH, onFinish);

}

function onFinish(e:TweenEvent) {
    removeChild(dropBall1);
}

还要确保为TweenEvent类添加必要的import语句:

import fl.transitions.TweenEvent;

答案 1 :(得分:0)

Tween对象调度类型为Event

TweenEvent.MOTION_FINISH(更准确地说是:TweenEvent)