Suppose you have a MyView.mxml file, which is basically a Panel with several children (Form, FormItems, Buttons...).
Is it possible to iterate over the MyView and get all the information about its children (types, id ...) before it is displayed.
In my Main.mxml if I have this function
public function iterateOverChildren(comp:Container):void {
// Get the number of descriptors.
trace("Running iterateOverChildren for " + comp.id);
if (comp != null)
{
var n:int = comp.childDescriptors.length;
for (var i:int = 0; i < n; i++) {
var c:ComponentDescriptor = comp.childDescriptors[i];
var d:Object = c.properties;
// Log ids and types of objects in the Array.
trace(c.id + " is of type " + c.type);
// Log the properties added in the MXML tag of the object.
for (var p:String in d) {
trace("Property: " + p + " : " + d[p]);
}
}
}
}
Why does this call not work ?
var myV = MyView(); iterateOverChildren(myV);
It only works if I add a statement like addChild(myV); before the iterateOverChildren call. (But that's not what I want, I want to iterate the descriptions without adding it to display).
When I read this http://livedocs.adobe.com/flex/3/html/help.html?content=layoutperformance%5F06.html
I thought the "childDescriptors" method is independent from the life cycle, it would let me introspect the component without adding to display. What did I miss ? How do I introspect a component before displayed.