Adobe FLEX 2 - CREATING AND EXTENDING COMPONENTS Manual page 141

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

Advertisement

Custom components that extend existing Flex classes inherit all the events of the superclass. If
you extend the
Button
from the Button class, such as
shows:
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:MyComp="myComponents.*">
<mx:Script>
<![CDATA[
import flash.events.Event;
private function handleClick(eventObj:Event):void {
// Define event listener.
}
private function handleCreationComplete(eventObj:Event):void {
// Define event listener.
}
]]>
</mx:Script>
<MyComp:MyButton
click="handleClick(event);"
creationComplete="handleCreationComplete(event);"/>
</mx:Application>
Your custom components can also define new events based on the requirements of your
components. For example, the section
on page 132
showed how to define a custom event so that properties of your component can
work with the Flex data binding mechanism.
This section describes how to handle events within a custom component and how to create
events for it.
Handling predefined events within the component
The previous section showed a custom component, MyButton, dispatching two events. In
that section, you defined the event listeners in the main application file.
class to create the MyButton class, you can use the events inherited
or
mouseOver
"Using data binding with custom properties"
, as the following example
creationComplete
Defining events in ActionScript components
141

Advertisement

Table of Contents
loading

Table of Contents