Writing An Effect For A Transition - 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

In this example, Tween object invokes the
interval, passing it values between
Tween object calls the
invoking the
onTweenUpdate()
of the effect, the target component displays a smooth animation as it rotates.
You use your new effect in an MXML application, as the following example shows:
<?xml version="1.0"?>
<!-- effects/MainRotation.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:MyComp="myEffects.*">
<MyComp:Rotation id="Rotate90"
angleFrom="0" angleTo="360"
duration="1000"/>
<mx:Image source="@Embed(source='../assets/myImage.jpg')"
mouseDownEffect="{Rotate90}"/>
</mx:Application>
In this example, you use the effect to rotate an image when the user clicks it.

Writing an effect for a transition

Transitions define how a change of view state appears on the screen. You define a transition by
using a combination of the Flex effect classes. For more information on transitions, see
Chapter 28, "Using Transitions," in Flex 2 Developer's Guide.
You can define your own custom effects for use in transitions. To do so, you have to account
for the effect being used in a transition when you override the
method. The
EffectInstance.play()
effect properties when the effect is used in a transition.
Defining the default values for a transition effect
Like any effect, an effect in a transition has properties that you use to configure it. For
example, most effects have properties that define starting and ending information for the
target component, such as the
240
Creating Effects
onTweenUpdate()
angleFrom
callback method with a value of
onTweenUpdate()
callback method at regular intervals throughout the duration
method must be able to determine default values for
,
xFrom
yFrom
callback method on a regular
and
. At the end of the effect, the
angleTo
EffectInstance.play()
,
, and
properties of the
xTo
yTo
. By
angleTo
Move
effect.

Advertisement

Table of Contents
loading

Table of Contents