rss twitter

Trace all DisplayObject’s children

Just cleaned up my development folder as stumbling upon that little script to trace every children
(and it's children) in a specific DisplayObject:

Actionscript:
  1. traceDisplayList(allCon, "=>");
  2.  
  3. function traceDisplayList(container:DisplayObjectContainer, indentString:String = ""):void {
  4.      var child:DisplayObject;
  5.  
  6.      for (var i:uint=0; i <container.numChildren; i++) {
  7.           child = container.getChildAt(i);
  8.           trace(indentString, child.parent.name + " " + indentString + " " + child.name);
  9.  
  10.           if (container.getChildAt(i) is DisplayObjectContainer) {
  11.                traceDisplayList(DisplayObjectContainer(child), indentString + "");
  12.           }
  13.      }
  14. }
  15.  
  16. // => allCon => container00
  17. // => container00 => clipA
  18. // => container00 => clipB
  19. // => container00 => clipC
  20. // => ClipC => ClipC1
  21. // => ClipC => ClipC2
  22. // ...

Tough miniscript to get a whole detailed trace of every children's children in the passed DisplayObject. Used that once for debugging but was surprised now it's still working :)

2 Responses to “Trace all DisplayObject’s children”

  1. It's funny, I made a similar code snippet a long time ago. I'm sure a lot of people did, but with IDE's like FDT these are redundant.

    I cleaned out my lib the other day as well, just got rid of all this stuff. I also dropped FP9 support out of my lib, no use in maintaining it any more. It's all about new stuff!

    Thx for the post! :)

  2. Its like you learn my mind! You seem to know a lot about this, like you wrote the guide in it or something. I feel that you just could do with a few p.c. to drive the message house a little bit, however instead of that, this is great blog. An excellent read. I will definitely be back.

Leave a Reply

Powered by WordPress | Free T-Mobile Phones for Sale | Thanks to Palm Pre Blog, Video Game Music and Get Six Pack Abs