User Guide

102 Creating Advanced MXML Components
You can also use the parentDocument property to reference the next object up in the
document chain of a Flex application. The
parentDocument property is inherited by all
components from the UIComponent class. For an MXML component, the
parentDocument
property references the Object corresponding to the component that referenced the MXML
component.
For more information on the
mx.core.Application.application static property and the
the
parentDocument property, see Chapter 14, “Using the Application Container,” on
page 571, in Flex 2 Developers Guide.
Even if the calling file does not pass a reference to the Application object, you can always
access it from your MXML component. For example, the following application contains a
custom component called StateComboBoxDirectRef. In this example,
StateComboBoxDirectRef is designed to write the index of the selected item in the
ComboBox to the TextArea control:
<?xml version="1.0"?>
<!-- mxmlAdvanced/MainDirectRef.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:MyComp="myComponents.*">
<mx:TextArea id="myTAMain"/>
<MyComp:StateComboBoxDirectRef/>
</mx:Application>