Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 如何使用greensock在as3中连接多个对象?_Actionscript 3_Gsap - Fatal编程技术网

Actionscript 3 如何使用greensock在as3中连接多个对象?

Actionscript 3 如何使用greensock在as3中连接多个对象?,actionscript-3,gsap,Actionscript 3,Gsap,我需要制作一个动画,有500个左右的物体从左到右飞行,具有不同的延迟、持续时间和目的地。 但是,一旦所有对象都已到达目的地,我需要运行另一个函数 每次当一个物体完成飞行时,我都试着做一个循环检查。即: ... for(var i:int = 0; i < objs.length; i++) Tweenlite.to(obj[i], duration, {delay:delay, x:destination.x, y:destination.y, onComplete:CheckAl

我需要制作一个动画,有500个左右的物体从左到右飞行,具有不同的延迟、持续时间和目的地。 但是,一旦所有对象都已到达目的地,我需要运行另一个函数

每次当一个物体完成飞行时,我都试着做一个循环检查。即:

...
for(var i:int = 0; i < objs.length; i++)
    Tweenlite.to(obj[i], duration, {delay:delay, x:destination.x, y:destination.y, onComplete:CheckAllComplete});
...

private function CheckAllComplete():void
{
    for(var i:int =0 ;i < objs.length; i++)
    {
        if(Tweenlite.getTweensOf(obj[i]).length > 0)
            return;
    }
    ... // if all the flights complete
}

基于您自己的代码,我没有检查是否工作或有任何错误

 private var tweenObjectsIndex:uint = 0;
 private var numObjects:uint = objs.length;

 for(var i:int = 0; i < numObjects:uint; i++)
 Tweenlite.to(obj[i], duration, {delay:delay, x:destination.x, y:destination.y, onComplete:CheckAllComplete});

  private function CheckAllComplete():void
  {
       tweenObjectsIndex++;
       // if all the flights complete
       if(tweenObjectsIndex == numObjects) // do something
  }

我相信您可以创建一个索引,并在每次完成a Tween并检查该索引是否等于您的对象数时增加它。如果是这样的话,你可以停止这个过程。你是说没有任何方法可以通过一个onComplete回调来处理tween吗?有很多方法可以处理,我只举了一个例子。好的,但是,实际上,我想寻找一个解决方案,可以避免检查每个tween。
 private var tweenObjectsIndex:uint = 0;
 private var numObjects:uint = objs.length;

 for(var i:int = 0; i < numObjects:uint; i++)
 Tweenlite.to(obj[i], duration, {delay:delay, x:destination.x, y:destination.y, onComplete:CheckAllComplete});

  private function CheckAllComplete():void
  {
       tweenObjectsIndex++;
       // if all the flights complete
       if(tweenObjectsIndex == numObjects) // do something
  }