Chapter 4: Creating Custom Events - Adobe FLEX 2 - CREATING AND EXTENDING COMPONENTS Manual

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 base class.
Therefore, if you extend the
event, and the events that all controls inherit, such as
following example shows:
<?xml version="1.0"?>
<!-- events/MyApplication.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:MyComp="myComponents.*">
<mx:Script>
<![CDATA[
import flash.events.Event;
// Event listener for the click event.
private function handleClick(eventObj:Event):void {
// Define event listener.
}
// Event listener for the initialize event.
private function handleInit(eventObj:Event):void {
// Define event listener.
}
]]>
</mx:Script>
<MyComp:MyButton
click="handleClick(event);"
initialize="handleInit(event);"/>
</mx:Application>
In addition to using the events inherited from its superclasses, your custom components can
define custom events. You use custom events to support data binding, to respond to user
interactions, or to trigger actions by your component.
For more information on the Flex event mechanism, see Chapter 5, "Using Events," in Flex 2
Developer's Guide.
36
Creating Custom Events
Button
class to create the MyButton class, you can use the
or
mouseOver
initialize
click
, as the

Advertisement

Table of Contents
loading

Table of Contents