Adobe FLEX 2 - CREATING AND EXTENDING COMPONENTS Manual page 238

Creating and extending flex 2 components
Hide thumbs Also See for FLEX 2 - CREATING AND EXTENDING COMPONENTS:
Table of Contents

Advertisement

When you define effects based on the TweenEffect class, you must override the
TweenEffectInstance.onTweenUpdate
TweenEffectInstance.onTweenEnd
This section describes how to create a tween effect. However, Flex supplies the
AnimateProperty class that you can use to create a tween effect for a single property of the
target component. For more information, see Chapter 17, "Using Behaviors," in Flex 2
Developer's Guide.
Example: Creating a tween effect
In this example, you create a tween effect that rotates a component in a circle. This example
implements a simplified version of the Rotate effect. The rotation is controlled by two
parameters that are passed to the effect:
package myEffects
{
// myEffects/Rotation.as
import mx.effects.TweenEffect;
import mx.effects.EffectInstance;
import mx.effects.IEffectInstance;
public class Rotation extends TweenEffect
{
// Define parameters for the effect.
public var angleFrom:Number = 0;
public var angleTo:Number = 360;
// Define constructor with optional argument.
public function Rotation(targetObj:* = null) {
super(targetObj);
instanceClass= RotationInstance;
}
// Override getAffectedProperties() method to return "rotation".
override public function getAffectedProperties():Array {
return ["rotation"];
}
// Override initInstance() method.
override protected function initInstance(inst:IEffectInstance):void
{
super.initInstance(inst);
RotationInstance(inst).angleFrom = angleFrom;
RotationInstance(inst).angleTo = angleTo;
}
}
}
238
Creating Effects
() method, and optionally override the
() method.
and
angleFrom
angleTo
:

Advertisement

Table of Contents
loading

Table of Contents