Defining A Custom Effect Trigger - 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

x="0" y="0" width="100" height="100"
click="currentState='One'" >
<mx:Label fontSize="24" text="One"/>
</mx:Panel>
<mx:Panel id="p2" title="Two"
x="0" y="110" width="100" height="100"
click="currentState='Two'" >
<mx:Label fontSize="24" text="Two"/>
</mx:Panel>
<mx:Panel id="p3" title="Three"
x="110" y="0" width="200" height="210"
click="currentState=''" >
<mx:Label fontSize="24" text="Three"/>
</mx:Panel>
</mx:Canvas>
</mx:Application>

Defining a custom effect trigger

You can create a custom effect trigger to handle situations for which the standard Flex triggers
do not meet your needs. An effect trigger is paired with a corresponding event that invokes
the trigger. For example, a
trigger. The event initiates the corresponding effect trigger when a user clicks a component.
You use the
mouseDown
the component. You use the
Suppose that you want to apply an effect that sets the brightness level of a component when a
user action occurs. The following example shows a custom Button control that uses a new
property,
, and dispatches two new events,
bright
the
property. The control also defines two new effect triggers,
bright
, which are paired with the
brightenEffect
<?xml version="1.0"?>
<!-- effects\myComponents\MyButton.mxml -->
<mx:Button xmlns:mx="http://www.adobe.com/2006/mxml" >
<mx:Metadata>
<!-- Define the metadata for the events and effect triggers. -->
[Event(name="darken", type="flash.events.Event")]
[Event(name="brighten", type="flash.events.Event")]
[Effect(name="darkenEffect", event="darken")]
[Effect(name="brightenEffect", event="brighten")]
</mx:Metadata>
<mx:Script>
<![CDATA[
import flash.events.Event;
Button
control has a
event to specify the event listener that executes when the user selects
mouseDownEffect
event and a
mouseDown
trigger to associate an effect with the trigger.
and
darken
brighten
event and the
darken

Defining a custom effect trigger

mouseDownEffect
, based on changes to
and
darkenEffect
event.
brighten
247

Advertisement

Table of Contents
loading

Table of Contents