Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.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 检测阵列中的最后一项何时停止_Actionscript 3_Algorithm - Fatal编程技术网

Actionscript 3 检测阵列中的最后一项何时停止

Actionscript 3 检测阵列中的最后一项何时停止,actionscript-3,algorithm,Actionscript 3,Algorithm,我有一个精灵数组,我通过增加它们的rotationX属性来设置它的动画。我想要的是,一旦数组中的最后一个项完成循环,它们就会全部消失。问题是它们的旋转速度是由一个随机函数产生的,所以我不能只到数组的末尾去寻找最后一个。每一次都是不同的 所以我有一组精灵: for(var i:int=0; i<arrSprites.length; i++) { addChild(arrSprites[i]) ; } 我的经纪人: private function loop(e:Event):

我有一个精灵数组,我通过增加它们的rotationX属性来设置它的动画。我想要的是,一旦数组中的最后一个项完成循环,它们就会全部消失。问题是它们的旋转速度是由一个随机函数产生的,所以我不能只到数组的末尾去寻找最后一个。每一次都是不同的

所以我有一组精灵:

for(var i:int=0; i<arrSprites.length; i++)
{
    addChild(arrSprites[i]) ;   
}
我的经纪人:

private function loop(e:Event):void
{
    for(var i:int=0; i<arrSprites.length; i++)
    {
        var currentSprite:Sprite = arrSprites[i];
        if(currentSprite.rotationX < 361) //this will detect the first one 
                                                      //to finish but I want the last 
            {
                currentSprite.rotationX += arrSprites[i].speed; //random speed
            }
            else
            {
                deleteTheSprites(); //removes all sprites and does other stuff
            }


        }
    }
私有函数循环(e:事件):无效
{
对于(var i:int=0;i
private函数循环(e:Event):void
{
var finished:int=0;//将计算完成的精灵数
对于每个(var电流:arrSprites中的精灵)
{
如果(current.rotationX<361)current.rotationX+=当前速度;
else if(++finished==arrSprites.length)deletetetesprites();//仅当所有精灵都已完成时执行
}
}

精彩绝伦,是的,优雅。谢谢。
private function loop(e:Event):void
{
    for(var i:int=0; i<arrSprites.length; i++)
    {
        var currentSprite:Sprite = arrSprites[i];
        if(currentSprite.rotationX < 361) //this will detect the first one 
                                                      //to finish but I want the last 
            {
                currentSprite.rotationX += arrSprites[i].speed; //random speed
            }
            else
            {
                deleteTheSprites(); //removes all sprites and does other stuff
            }


        }
    }
private function loop(e:Event):void
{
    var finished : int = 0; // will count the number of sprites finished
    for each (var current:Sprite in arrSprites)
    {
        if (current.rotationX < 361) current.rotationX += current.speed;
        else if (++finished == arrSprites.length) deleteTheSprites();  // executes only if all sprites have finished
    }
}