User Guide
80 Creating Simple MXML Components
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
<mx:Script> tag. For
example, the following example specifies the
rowCount property and a listener for the close
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 78, you defined the component
StateComboBox.mxml by using the
<mx:ComboBox> tag as its root tag. Therefore,
StateComboBox.mxml defines a subclass of the ComboBox class.