Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)?

like image 913
redconservatory Avatar asked Feb 01 '11 20:02

redconservatory


1 Answers

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;
}
like image 191
Jeremy White Avatar answered Nov 15 '22 14:11

Jeremy White