retrieving children from parent container of a certain type
is it possible to retrieve all children of a certain type from a parent in actionscript 3? i only see getChildAt,getChildByName, is there a getchild of a certain type like get al开发者_JAVA技巧l childs of object type:Food?
function getChildrenOfType( p_parent:DisplayObjectContainer, p_class:Class ):Array
{
var result:Array = [];
for( var i:0; i < p_parent.numChildren; ++i )
{
if( p_parent.getChildAt(i) is p_class )
{
result.push( p_parent.getChildAt(i);
}
}
return result;
}
Might need some tweaking, but it would go something like that.
you should try this:
p_parent.numChildren which gives you total number of children inside a movieclip.
精彩评论