FLEX如何遍历复杂的控件

FLEX怎么遍历复杂的控件?
如何遍历控件?把VBOX跟HBOX结合布局成3*3九个框,比如以下的格式:
XML code


<canvas>
    <vbox>
       <vbox>
<label />
<vbox>
...
</vobx>
</vbox>
    </vbox>
</canvas>



我怎么取每个框的数入框数据?

------解决方案--------------------
递归.....................
------解决方案--------------------
控件的id.属性名
比如
<mx:TextInput x="533" y="107" width="148" id="txtName"/>
//取值
txtName.text;
------解决方案--------------------
思路1:不建议你去遍历组件去取数据。因为这样做灵活性也不好,如果里面多加两层Box,取值可能就有些乱了。
“VBOX跟HBOX结合布局成3*3九个框”,定义一个数据是2维数组用ArrayCollection,把他做成绑定对象。
依次与3*3的9个框 绑定上。最好是双向绑定上。可以利用<mx:Binding source="" destination=""/>
以后操作都是针对数据对象来操作,不用每次都去去组件的数值。

思路2:先去取组件的值,把你的3*3的9个框依次定义上ID,比如box_0_0, box_0_1, box_0_2, box_1_0 等等
以后去数据这样做
for (var i:int = 0; i < 3; i ++) {
for (var j:int = 0; j < 3; j ++) {
var value:String = this["box_"+ i +"_"+j ].text;
}
}

思路3:遍历组件(递归),下面是代码:
XML code
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                        layout="absolute">
    <mx:Script>
        <![CDATA[
            import mx.core.Container;
            
            private function walkAllNodes():void
            {
                walk(box.getChildren())
            }
            
            private function walk(children:Array):void
            {
                for each(var child:Object in children) {
                    
                    if (child is Container && Container(child).getChildren()) {
                        walk(Container(child).getChildren());
                    } else if (child is TextInput){
                        var value:String = TextInput(child).text;
                        trace(value);
                    }
                }
            }
        ]]>
    </mx:Script>
    <mx:VBox id="box">
        <mx:HBox>
            <mx:Label text="website"/>
            <mx:TextInput id="txtInput" text="1"/>
            <mx:HBox>
                <mx:TextInput text="2"/>
                <mx:HBox>
                    <mx:TextInput text="3"/>
                </mx:HBox>
                <mx:HBox>
                    <mx:TextInput text="4"/>
                </mx:HBox>
                    <mx:TextInput text="5"/>
            </mx:HBox>
        </mx:HBox>
        <mx:Button label="walkAllNodes" click="walkAllNodes()" />
    </mx:VBox>
</mx:Application>