当前位置: 动力学知识库 > 问答 > 编程问答 >

actionscript 3 - Get all children on the stage / parent Object

问题描述:

How do I get a list of all the children (Sprites) on the stage of my Document Class OR how can I get a list (length) of all the children (Sprites) of a parent (Sprite)?

网友答案:

One idea is that you could write a helper function that will do the work for you.

public function getChildrenOf(target:DisplayObjectContainer):Array
{
   var children:Array = [];

   for (var i:uint = 0; i < target.numChildren; i++)
      children.push(target.getChildAt(i));

   return children;
}
分享给朋友:
您可能感兴趣的文章:
随机阅读: