Adobe FLEX 2 - CREATING AND EXTENDING COMPONENTS Manual page 80

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

Advertisement

The StateComboBox.mxmlfile specifies the ComboBox control as its root tag, so you can
reference all of the properties of the ComboBox control within the MXML tag of your
custom component, or in the ActionScript specified within an
example, the following example specifies the
event for your custom control:
<?xml version="1.0"?>
<!-- mxml/MyApplicationProps.mxml-->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:local="*">
<mx:Script>
<![CDATA[
import flash.events.Event;
private function handleCloseEvent(eventObj:Event):void {
myTA.text="foo";
}
]]>
</mx:Script>
<local:StateComboBox rowCount="5" close="handleCloseEvent(event);"/>
<mx:TextArea id="myTA" />
</mx:Application>
MXML components and ActionScript classes
When you create a custom MXML component, you define a new ActionScript class where the
class name corresponds to the filename of the MXML component. Your new class is a subclass
of the component's root tag and, therefore, inherits all of the properties and methods of the
root tag. However, because you are defining the component in MXML, many of the
intricacies of creating an ActionScript class are hidden from you.
For example, in
"Creating MXML components" on page
StateComboBox.mxml by using the
StateComboBox.mxml defines a subclass of the ComboBox class.
80
Creating Simple MXML Components
property and a listener for the
rowCount
tag as its root tag. Therefore,
<mx:ComboBox>
tag. For
<mx:Script>
78, you defined the component
close

Advertisement

Table of Contents
loading

Table of Contents