Macromedia flex 2 Manual
About creating a custom effect
229
<!-- Define factory class. -->
<mx:WipeDown id="myWD" duration="1000"/>
<!-- Assign factory class to effect targets. -->
<mx:Button id="myButton" mouseDownEffect="{myWD}"/>
<mx:Button id="myOtherButton" mouseDownEffect="{myWD}"/>
<mx:WipeDown id="myWD" duration="1000"/>
<!-- Assign factory class to effect targets. -->
<mx:Button id="myButton" mouseDownEffect="{myWD}"/>
<mx:Button id="myOtherButton" mouseDownEffect="{myWD}"/>
By convention, the name of a factory class is the name of the effect, such as Zoom or Fade.
Instance class
The instance class implements the effect logic. When an effect trigger
occurs, or when you call the
play()
method to invoke an effect, the factory class creates an
object of the instance class to perform the effect on the target. When the effect ends, Flex
destroys the instance object. If the effect has multiple target components, the factory class
creates multiple instance objects, one per target.
destroys the instance object. If the effect has multiple target components, the factory class
creates multiple instance objects, one per target.
By convention, the name of an instance class is the name of the effect with the suffix Instance,
such as ZoomInstance or FadeInstance.
such as ZoomInstance or FadeInstance.
About the effect base classes
You define effects by creating a subclass from the effects class hierarchy. Typically, you create a
subclass from one of the following classes:
subclass from one of the following classes:
■
mx.effects.Effect
Create a subclass from this class for simple effects that do not require
an effect to play over a period of time. For example, the Pause effect inserts a delay
between two consecutive effects. You can also define a simple sound effect that plays an
MP3 file.
between two consecutive effects. You can also define a simple sound effect that plays an
MP3 file.
■
mx.effects.TweenEffect
Create a subclass from this class to define an effect that plays
over a period of time, such as an animation. For example, the Resize effect is a subclass of
the TweenEffect class that modifies the size of its target over a specified duration.
the TweenEffect class that modifies the size of its target over a specified duration.
About implementing your effects classes
You must override several methods and properties in your custom effect classes, and define
any new properties and methods that are required to implement the effect. You can optionally
override additional properties and methods based on the type of effect that you create.
any new properties and methods that are required to implement the effect. You can optionally
override additional properties and methods based on the type of effect that you create.