User Guide

38 Chapter 2: Using MXML
If the value of the shippingAddress property is a subclass of Address (such as DomesticAddress),
you can declare the property value as the following example shows:
<e:PurchaseOrder quantity="3" xmlns:e="example">
<e:shippingAddress>
<e:DomesticAddress name="Fred" street="123 Elm St."/>
</e:shippingAddress>
</e:PurchaseOrder>
If the property is explicitly typed as Object like the value property in the following example, you
can specify an anonymous object using the
<mx:Object> tag.
class ObjectHolder {
var value : Object
}
The following example shows how you specify an anonymous object as the value of the value
property:
<mynamespace:ObjectHolder>
<mynamespace:value>
<mx:Object foo='bar' />
</mynamespace:value>
</mynamespace:ObjectHolder>
Arrays of objects
When a component has a property that takes an Array of objects as its value, you can represent
the property in MXML using child tags, as the following example shows:
<mynamespace:MyComponent>
<mynamespace:nameOfProperty>
<mx:Array>
<objectType prop1="val1" prop2="val2"/>
<objectType prop1="val1" prop2="val2"/>
<objectType prop1="val1" prop2="val2"/>
</mx:Array>
</mynamespace:nameOfProperty>
</mynamespace:MyComponent>
The component in the following example contains an Array of ListItem objects. Each ListItem
object has properties named
label and data.
<mynamespace:MyComponent>
<mynamespace:dataProvider>
<mx:Array>
<mynamespace:ListItem label="One" data="1"/>
<mynamespace:ListItem label="Two" data="2"/>
</mx:Array>
</mynamespace:dataProvider>
</mynamespace:MyComponent>