<?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>


posted on 2012-03-07 12:08  星^_^風  阅读(271)  评论(0编辑  收藏  举报