Actionscript 动作脚本3,完成多次吐温后的动作

Actionscript 动作脚本3,完成多次吐温后的动作,actionscript,Actionscript,我是一个游戏开发的新手,现在我正在学习射击游戏。 我有个问题 在我的游戏中,我创建了三个tween动画: var myTween:Tween = new Tween(this, "scaleX", Back.easeIn, 1.2, 0, 10); var myTween2:Tween = new Tween(this, "scaleY", Back.easeIn, 1.2, 0, 10); var myTween3:Tween = new Tween(this, "alpha", None.e

我是一个游戏开发的新手,现在我正在学习射击游戏。 我有个问题

在我的游戏中,我创建了三个tween动画:

var myTween:Tween = new Tween(this, "scaleX", Back.easeIn, 1.2, 0, 10);
var myTween2:Tween = new Tween(this, "scaleY", Back.easeIn, 1.2, 0, 10);
var myTween3:Tween = new Tween(this, "alpha", None.easeIn, 1, 0, 10);
当敌人的生命值为零时,会出现这种情况, 我的意图是在动画之后,剪辑将从舞台上移除

我的问题是,有没有办法知道所有这些孩子都完蛋了?我试图为每个tween应用TweenEvent.MOTION\u FINISH事件,但如果我这样做,我必须创建三个listenesr(如果我想创建十个tween,这将是一个问题)


谢谢

因为所有tween都在相同的时间内运行,您能否将侦听器添加到最后一个tween中,并且当处理程序执行时,您将知道它们都已完成

或者,您可以这样做:

import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import fl.motion.easing.Back;
import fl.transitions.easing.None;

// Populate an array with the tweens
var tweens:Array = [];
tweens.push(new Tween(this, "scaleX", Back.easeIn, 1.2, 0, 10));
tweens.push(new Tween(this, "scaleY", Back.easeIn, 1.2, 0, 10));
tweens.push(new Tween(this, "alpha", None.easeIn, 1, 0, 10));

// Finished tweens count
var finishedCount:int = 0;

// Loop through all the tweens and add a handler for the motion finished event
for (var i:int = 0; i < tweens.length; i ++)
{
    // Each of the tweens motion finished event can be assigned to the same handler
    Tween(tweens[i]).addEventListener(TweenEvent.MOTION_FINISH, motionFinishedHandler);
}

function motionFinishedHandler(e:TweenEvent):void
{
    // Good practice to remove the event listener when it is no longer needed
    e.target.removeEventListener(TweenEvent.MOTION_FINISH, motionFinishedHandler);

    // Increment the count and test whether it equals the number of tweens
    if (++ finishedCount == tweens.length)
        trace("Finished");
}
导入fl.transitions.Tween;
导入fl.transitions.TweenEvent;
导入fl.motion.easing.Back;
导入fl.transitions.easing.None;
//用tweens填充数组
变量tweens:Array=[];
推(新的推(这个“scaleX”,Back.easeIn,1.2,0,10));
推(新的推(这个“scaleY”,Back.easeIn,1.2,0,10));
推(新的推(这个“alpha”,无,1,0,10));
//成品吐温计数
var finishedCount:int=0;
//循环遍历所有tween并为motion finished事件添加处理程序
for(变量i:int=0;i

您可能还想考虑在Flash中动画对象的标准,这将允许您在一次调用中对同一对象的多个属性进行编程。p> 格林斯托克的TweenLite和TimelineLite为+1。

使吐温一切更干净,更容易