Adding Events To Custom Components - MACROMEDIA FLEX - DEVELOPING COMPONENTS AND THEMES Manual

Developing flex components and themes in flash authoring
Table of Contents

Advertisement

If your custom SWC file has properties typed Array, do not use data binding to supply initial
values for array properties. For example, if your custom SWC file has a
typed Array, do not use data binding in the MXML as the following example shows:
<yourSWC labels={myArray}/>
<mx:Script>
<![CDATA[
var myArray=["cat", "dog", "bird"];
]]>
</mx:Script>
The problem is that Flex instantiates the SWC file before data binding occurs. Instead, you define
the array using the
<yourSWC>
<labels>
<mx:Array>
<mx:String>cat</mx:String>
<mx:String>dog</mx:String>
<mx:String>bird</mx:String>
</mx:Array>
</labels>
</yourSWC>

Adding events to custom components

All visual controls inherit a large set of events from the base classes, UIObject and UIComponent.
From the UIComponent class, components inherit events such as
and
. From the UIObject class, components inherit events such as
keyUp
, and
mouseOver
Developing Flex Applications.
Components can emit and consume events. In most cases, you want your component to emit an
event and the MXML application to consume and handle it.
Custom components that extend existing Flex classes inherit those events. For example, if you
extend the mx.controls.Button class, you have the set of click-related events at your disposal, in
addition to the events that all controls inherit, such as
This section describes how to add event handling and emitting functionality to your custom
components.
Handling the initialize event
When Flex finishes creating a component, it emits the component's
event is used by MXML developers to populate data, debug, or perform some other function
before the user starts interacting with the application.
tag, as the following example shows:
<mx:Array>
. For a complete list of UIObject and UIComponent events, see
mouseOut
labels
,
focusIn
focusOut
mouseDown
and
mouseOver
mouseDown
initialize

Adding events to custom components

property that is
,
,
keyDown
,
,
mouseUp
.
event. This
33

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLEX - DEVELOPING COMPONENTS AND THEMES and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flex

Table of Contents