/** * Outputs hierarchy of children for chosen DisplayObjectContainer. * @param what container to show childs of * @param c (optional) Initial level (tab count) */ public function traceChildren(what:DisplayObjectContainer, c:int = 0):void { var j:int, child:DisplayObject, out:String; for (var i:int = 0, l:int = what.numChildren; i < l; i++) { child = what.getChildAt(i); // add 'tabs' before text: for (j = 0, out = ''; j < c; j++) out += '. '; // add component's toString(): out += child.toString(); // display output: trace(out); // if child is container too, trace its children: if (child is DisplayObjectContainer) { traceChildren(child as DisplayObjectContainer, c + 1); } } }
ActionScript3 – show DisplayObject hierarchy
This simple function will output (trace) hierarchy of chosen DisplayObjectContainer when called. This is useful for looking up what's added to stage "overall" or just checking how many nodes does your movie has.