Specifications
CHAPTER 5
100
Depending on the value of the creationPolicy property, Flex immediately begins instantiating controls inside
the containers or it defers their instantiation. If instantiation is deferred, you can use the properties of this Array
to access the ComponentDescriptor of each component and create that object at a specified time.
The
childDescriptors property points to an Array of objects, so you can use Array functions, such as length,
to iterate over the children, as the following example shows:
<?xml version="1.0"?>
<!-- layoutperformance/AccessChildDescriptors.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script><![CDATA[
import mx.core.ComponentDescriptor;
import flash.utils.*;
public function iterateOverChildren():void {
// Get the number of descriptors.
var n:int = tile.childDescriptors.length;
for (var i:int = 0; i < n; i++) {
var c:ComponentDescriptor = tile.childDescriptors[i];
var d:Object = c.properties;
// Log ids and types of objects in the Array.
ta1.text += c.id + " is of type " + c.type + "\n";
// Log the properties added in the MXML tag of the object.
for (var p:String in d) {
ta1.text += "Property: " + p + " : " + d[p] + "\n";
}
}
}
]]></mx:Script>
<mx:Tile id="tile" creationComplete="iterateOverChildren();">
<mx:TextInput id="myInput" text="Enter text here"/>
<mx:Button id="myButton" label="OK" width="150"/>
</mx:Tile>
<mx:TextArea id="ta1" height="150" width="250"/>
</mx:Application>
Properties of the ComponentDescriptor include id, type, and properties. The properties property points to
an object that contains the properties that were explicitly added in the MXML tag. This object does not store
properties such as styles and events.










