# Actionscript 3.0 looping through stage and DisplayObject items

**URL:** <https://forum.kirupa.com/t/actionscript-3-0-looping-through-stage-and-displayobject-items/294057>\
**Category:** flash\
**Created:** [August 7, 2009, 4:51pm UTC](https://forum.kirupa.com/t/actionscript-3-0-looping-through-stage-and-displayobject-items/294057 "2009-08-07T16:51:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![clem\_c\_rock](https://avatars.discourse-cdn.com/v4/letter/c/c6cbf5/32.png) [@clem\_c\_rock](https://forum.kirupa.com/u/clem_c_rock)\
**Post date:** [August 7, 2009, 4:51pm UTC](https://forum.kirupa.com/t/actionscript-3-0-looping-through-stage-and-displayobject-items/294057/1 "2009-08-07T16:51:40Z")

</div>

Hello,  
I’m trying to convert to Actionscript 3.0 and I’m trying to find out how to loop through Stage objects as well as DisplayObject.

With AS 2.0 - I would only have to do:

```auto

for(var i in _root) // or MovieClip, this, ect
{
    trace("i: " + i + " *: " + _root.*);
}

In AS 3.0 I found this equivalent which works w/ some objects:

```

public function debug\_object(o:Object, show\_all:Boolean):void  
{  
import flash.utils.\*;  
var def:XML = describeType(o);  
var props:XMLList = def…variable.@name;  
if(show\_all) props += def…accessor.@name;

```
for each (var prop:String in props)
{
    trace(prop + ": " + o[prop]);
}

```

}

this.showChildren(Stage);

```auto

This kind of works but the o[prop] always traces undefined and it's not showing any movieClips on the stage.

I would like to be able to have the debug object function be able to take Stage and DisplayObject arguments like such:

```

this.debug\_object(Stage, true);  
this.debug\_object(flash.display.DisplayObject, true);

```auto

Any ideas on how I could achieve this?

Thanks,
Clem C
```
