Macromedia flex 2 Manuel

Page de 254
Writing an effect for a transition
243
5.
Flex applies the destination view state to the application.
6.
Flex dispatches the 
currentStateChange
 event.
7.
Flex plays the effects defined in the transition. 
As part of playing the effect, Flex invokes the factory class 
play()
 method, 
Effect.play()
, to initialize 
propertyChanges.end
 for effect instances. 
Example: Creating a transition effect
This section modifies the Rotation effect created in 
 to make the effect usable in a transition. 
The following example shows the RotationTrans.as class that definesthe factory class for the 
effect. The only modification you make to Rotation.as to create RotationTrans.as is to remove 
the default value definitions for the 
angleFrom
 and 
angleTo
 property definitions. The 
RotationTransInstance.play()
 method determines the default values. 
package myEffects
{
    // myEffects/RotationTrans.as
    import mx.effects.TweenEffect;
    import mx.effects.EffectInstance;
    import mx.effects.IEffectInstance;
    public class RotationTrans extends TweenEffect
    {
        // Define parameters for the effect.
        // Do not specify any default values. 
        // The default value of these properties is NaN.
        public var angleFrom:Number;
        public var angleTo:Number;
  
        // Define constructor with optional argument.
        public function RotationTrans(targetObj:Object = null) {
            super(targetObj);
            instanceClass= RotationTransInstance;           
        }
        // 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);
            RotationTransInstance(inst).angleFrom = angleFrom;