User Guide
Working with events 113
To propagate the close event outside of the custom component, you define an event listener
for it in the MXML component that redispatches it, as the following example shows:
<?xml version="1.0"?>
<!-- mxmlAdvanced/myComponents/AddressForm.mxml -->
<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:local="*">
<mx:Metadata>
[Event(name="close", type="flash.events.Event")]
</mx:Metadata>
<mx:Script>
<![CDATA[
import flash.events.Event;
// Redispatch event.
private function handleCloseEventInternal(eventObj:Event):void {
dispatchEvent(eventObj);
}
]]>
</mx:Script>
<mx:FormItem label="Name">
<mx:TextInput id="name1" />
</mx:FormItem>
<mx:FormItem label="Street">
<mx:TextInput id="street" />
</mx:FormItem>
<mx:FormItem label="City" >
<mx:TextInput id="city" />
</mx:FormItem>
<mx:FormItem label="State" >
<mx:ComboBox close="handleCloseEventInternal(event);">
<mx:dataProvider>
<mx:Array>
<mx:String>AK</mx:String>
<mx:String>AL</mx:String>
</mx:Array>
</mx:dataProvider>
</mx:ComboBox>
</mx:FormItem>
</mx:Form>