Adobe FLEX 2 - CREATING AND EXTENDING COMPONENTS Manual page 108

Creating and extending flex 2 components
Hide thumbs Also See for FLEX 2 - CREATING AND EXTENDING COMPONENTS:
Table of Contents

Advertisement

The following example uses the StateComboBox.mxml component, and defines the event
listener for the component's
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:MyComp="*">
<mx:Script>
<![CDATA[
import flash.events.Event;
public function handleCloseEvent(eventObj:Event):void {
...
}
]]>
</mx:Script>
<MyComp:StateComboBox rowCount="5" close="handleCloseEvent(event);"/>
</mx:Application>
In this example, if the MXML component dispatches a
calling MXML file handles it.
Alternatively, you could define the event listener within the StateComboBox.mxml
component, as the following example shows:
<?xml version="1.0"?>
<!-- StateComboBox.mxml -->
<mx:ComboBox xmlns:mx="http://www.adobe.com/2006/mxml"
close="handleCloseEvent(event);">
<mx:Script>
<![CDATA[
import flash.events.Event;
public function handleCloseEvent(eventObj:Event):void {
...
}
]]>
</mx:Script>
<mx:dataProvider>
<mx:String>AK</mx:String>
<mx:String>AL</mx:String>
</mx:dataProvider>
</mx:ComboBox>
108
Creating Advanced MXML Components
event in the main application:
close
event, the event listener in the
close

Advertisement

Table of Contents
loading

Table of Contents