I dont think there is a built-in function that returns all children.
It wouldn't be difficult to write a recursive function that recurses
through the display list and gets all child display objects though.
regards,
Bjorn
On 02/10/2007, at 12:11 PM, flexawesome wrote:
Hi there,
is there a way to get all children in application? in the following
code, I can get the button_1, panel_1 only. However, can't get the
button_2 inside the panel.
can I get all children in whole application without knowing the
container structure?
THANKS
===========================================================
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="init();">
<mx:Script>
<![CDATA[
import mx.core.UIComponent;
private var childrenLength:Number;
private var targetObj:Object;
private var targetType:String;
private var startPos:Number;
private var endPos:Number;
private function init():void {
addEventListener(MouseEvent.MOUSE_OVER, getNum);
}
private function getNum(event:MouseEvent):void{
event.preventDefault();
checkContainer(event);
}
private function checkContainer(event:MouseEvent):void{
childrenLength = UIComponent(event.currentTarget).numChildren;
for (var i:uint=0; i < childrenLength; i++) {
targetObj = UIComponent(event.currentTarget).getChildAt(i);
targetType = getQualifiedClassName(targetObj);
trace(targetObj);
}
}
]]>
</mx:Script>
<mx:Button id="Button_1" label="Button1"/>
<mx:Panel id="Panel_1" width="250" height="200" layout="absolute">
<mx:Button id="Button_2" x="79" y="35" label="Button2"/>
</mx:Panel>
</mx:Application>
===========================================================