MACROMEDIA FLEX - DEVELOPING COMPONENTS AND THEMES Manual page 34

Developing flex components and themes in flash authoring
Table of Contents

Advertisement

Because nearly all classes extend the UIObject class, the
custom components. To define a handler for it, you add the
component's MXML tag, and then add ActionScript code that processes the event, as the
following example shows:
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" xmlns="*">
<mx:Script>
<![CDATA[
function myInit() {
trace('init greensquare');
}
]]>
</mx:Script>
<greensquare initialize="myInit();" />
</mx:Application>
Handling mouse events
All visual components that inherit from the UIObject class support a number of navigational
mouse events, including the following:
mouseOver
mouseOut
mouseDown
mouseUp
These events do not include the
components, see the information about the control in Developing Flex Applications.
To use the common mouse events, you point to a handler in your MXML file. You do not need
to add any additional code to the component source code.
The following example changes the alpha (transparency) of the Green Square component
when the mouse moves over the component, and again when the mouse moves away from
the component:
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" xmlns="*">
<mx:Script>
<![CDATA[
var startAlpha:Number = 40;
function myInit() {
myGS.alpha=startAlpha;
}
function changeAlpha(curAlpha:Number) {
myGS.alpha=curAlpha;
}
34
Chapter 2: Creating Basic Components in Flash MX 2004
event. For a complete list of events supported by visual
click
event is already supported in
initialize
property to the
initialize

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

This manual is also suitable for:

Flex

Table of Contents