| Package | mx.effects |
| Class | public class Effect |
| Inheritance | Effect EventDispatcher Object |
| Subclasses | AddChildAction, CompositeEffect, MaskEffect, RemoveChildAction, SetPropertyAction, SetStyleAction, SoundEffect, TweenEffect |
You do not create an instance of the Effect class itself in an application. Instead, you create an instance of one of the subclasses, such as Fade or WipeLeft.
MXML Syntax
Hide MXML Syntax
The Effect class defines the following properties, which all of its subclasses inherit:
<mx:tagname
Properties
customFilter=""
duration="500"
filter=""
repeatCount="1"
repeatDelay="0"
startDelay="0"
suspendBackgroundProcessing="false|true"
target="effect target"
targets="array of effect targets"
Events
effectEnd="No default"
efectStart="No default"
/>
See also
| Property | Defined by | ||
|---|---|---|---|
| className : String
[read-only]
The name of the effect class, such as
"Fade". | Effect | ||
![]() | constructor : Object
A reference to the class object or constructor function for a given object instance.
| Object | |
| customFilter : EffectTargetFilter
Specifies a custom filter object, of type EffectTargetFilter, used by
the effect to determine the targets on which to play the effect.
| Effect | ||
| duration : Number
Duration of the effect in milliseconds.
| Effect | ||
| filter : String
Specifies an algorithm for filtering targets for an effect.
| Effect | ||
| instanceClass : Class
An object of type Class that specifies the effect
instance class class for this effect class.
| Effect | ||
| isPlaying : Boolean
[read-only]
A read-only flag which is true if any instances of the effect
are currently playing, and false if none are.
| Effect | ||
![]() | prototype : Object
[static]
A reference to the prototype object of a class or function object.
| Object | |
| relevantProperties : Array
An Array of property names to use when performing filtering.
| Effect | ||
| relevantStyles : Array
An Array of style names to use when performing filtering.
| Effect | ||
| repeatCount : int = 1
Number of times to repeat the effect.
| Effect | ||
| repeatDelay : int = 0
Amount of time, in milliseconds, to wait before repeating the effect.
| Effect | ||
| startDelay : int = 0
Amount of time, in milliseconds, to wait before starting the effect.
| Effect | ||
| suspendBackgroundProcessing : Boolean = false
If
true, blocks all background processing
while the effect is playing. | Effect | ||
| target : Object
The UIComponent object to which this effect is applied.
| Effect | ||
| targets : Array
An Array of UIComponent objects that are targets for the effect.
| Effect | ||
| Method | Defined by | ||
|---|---|---|---|
|
Constructor.
| Effect | ||
![]() |
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener object with an EventDispatcher object so that the listener
receives notification of an event.
| EventDispatcher | |
|
captureStartValues():void
Captures the current values of the relevant properties
on the effect's targets.
| Effect | ||
|
createInstance(target:Object = null):IEffectInstance
Creates a single effect instance and initializes it.
| Effect | ||
|
Takes an Array of target objects and invokes the
createInstance() method on each target. | Effect | ||
![]() |
Dispatches an event into the event flow.
| EventDispatcher | |
|
end(effectInstance:IEffectInstance = null):void
Interrupts an effect that is currently playing,
and jumps immediately to the end of the effect.
| Effect | ||
|
Returns an Array of Strings, where each String is the name
of a property that is changed by this effect.
| Effect | ||
![]() |
Checks whether the EventDispatcher object has any listeners registered for a specific type
of event.
| EventDispatcher | |
|
pause():void
Pauses the effect until you call the
resume() method. | Effect | ||
|
Begins playing the effect.
| Effect | ||
![]() |
Removes a listener from the EventDispatcher object.
| EventDispatcher | |
|
resume():void
Resumes the effect after it has been paused
by a call to the
pause() method. | Effect | ||
|
reverse():void
Plays the effect in reverse, if the effect is currently playing,
starting from the current position of the effect.
| Effect | ||
![]() |
Sets the availability of a dynamic property for loop operations.
| Object | |
![]() |
Returns the string representation of the specified object.
| Object | |
![]() |
Returns the primitive value of the specified object.
| Object | |
![]() |
Checks whether an event listener is registered with this EventDispatcher object or any of
its ancestors for the specified event type.
| EventDispatcher | |
| Method | Defined by | ||
|---|---|---|---|
|
Used internally by the Effect infrastructure.
| Effect | ||
|
effectEndHandler(event:EffectEvent):void
Called when an effect instance has finished playing.
| Effect | ||
|
effectStartHandler(event:EffectEvent):void
This method is called when the effect instance starts playing.
| Effect | ||
|
Determines the logic for filtering out an effect instance.
| Effect | ||
|
Called by the
captureStartValues() method to get the value
of a property from the target. | Effect | ||
|
initInstance(instance:IEffectInstance):void
Copies properties of the effect to the effect instance.
| Effect | ||
| Event | Summary | Defined by | ||
|---|---|---|---|---|
![]() | Dispatched when Flash Player gains operating system focus and becomes active. | EventDispatcher | ||
![]() | Dispatched when Flash Player loses operating system focus and is becoming inactive. | EventDispatcher | ||
Dispatched when the effect finishes playing,
either when the effect finishes playing or when the effect has
been interrupted by a call to the end() method. | Effect | |||
| Dispatched when the effect starts playing. | Effect | |||
| className | property |
className:String [read-only]
The name of the effect class, such as "Fade".
This is a short, or unqualified, class name
that does not include the package name.
If you need the qualified name, use the
getQualifiedClassName() method
in the flash.utils package.
public function get className():String
| customFilter | property |
customFilter:EffectTargetFilter [read-write]Specifies a custom filter object, of type EffectTargetFilter, used by the effect to determine the targets on which to play the effect.
Target filtering is only performed if you call
the captureStartValues() method before playing the effect.
Flex automatically calls the captureStartValues() method
when the effect is part of a transition.
Use the filter property for simple filtering.
If the customFilter property is non-null,
the filter property is ignored.
The default value is null.
public function get customFilter():EffectTargetFilter
public function set customFilter(value:EffectTargetFilter):void
See also
| duration | property |
duration:Number [read-write]Duration of the effect in milliseconds.
In a Parallel or Sequence effect, the duration property
sets the duration of each effect. For example, if a Sequence effect
has its duration property set to 3000,
each effect in the Sequence takes 3000 ms to play.
For a repeated effect, the duration property
specifies the duration of a single instance of the effect.
Therefore, if an effect has a duration property
set to 2000, and a repeatCount property set to 3,
the effect takes a total of 6000 ms (6 seconds) to play.
The default value is 500.
public function get duration():Number
public function set duration(value:Number):void
| filter | property |
filter:String [read-write]Specifies an algorithm for filtering targets for an effect. A value of null specifies no filtering.
Target filtering is only performed if you call
the captureStartValues() method before playing the effect.
Flex automatically calls the captureStartValues() method
when the effect is part of a transition.
Use this property for simple filtering.
Use the customFilter property for more complex filtering.
If the customFilter property has a non-null value,
this property is ignored.
You can use the following values for the filter
property:
"add" plays the effect on any targets
that are added as a child to a container."hide" plays the effect on any targets
whose visible property changed from true to
false."move" plays the effect on any targets
that changed their x or y
properties."remove" plays the effect on any targets
that are removed as a child of a container."resize" plays the effect on any targets
that changed their width or height
properties."show" plays the effect on any targets
whose visible property changed from false to
true."" specifies no filtering.The default value is null.
public function get filter():String
public function set filter(value:String):void
| instanceClass | property |
public var instanceClass:ClassAn object of type Class that specifies the effect instance class class for this effect class.
All subclasses of the Effect class must set this property in their constructor.
| isPlaying | property |
isPlaying:Boolean [read-only]A read-only flag which is true if any instances of the effect are currently playing, and false if none are.
Implementation public function get isPlaying():Boolean
| relevantProperties | property |
relevantProperties:Array [read-write]An Array of property names to use when performing filtering. This property is used internally and should not be set by effect users.
The default value is equal to the Array returned by
the getAffectedProperties() method.
public function get relevantProperties():Array
public function set relevantProperties(value:Array):void
| relevantStyles | property |
relevantStyles:Array [read-write]An Array of style names to use when performing filtering. This property is used internally and should not be set by effect users.
The default value is equal to the Array returned by
the getAffectedProperties() method.
public function get relevantStyles():Array
public function set relevantStyles(value:Array):void
| repeatCount | property |
public var repeatCount:int = 1
Number of times to repeat the effect.
Possible values are any integer greater than or equal to 0.
A value of 1 means to play the effect once.
A value of 0 means to play the effect indefinitely
until stopped by a call to the end() method.
The default value is 1.
| repeatDelay | property |
public var repeatDelay:int = 0Amount of time, in milliseconds, to wait before repeating the effect. Possible values are any integer greater than or equal to 0.
The default value is 0.
| startDelay | property |
public var startDelay:int = 0
Amount of time, in milliseconds, to wait before starting the effect.
Possible values are any int greater than or equal to 0.
If the effect is repeated by using the repeatCount property,
the startDelay is only applied to the first time
the effect is played.
The default value is 0.
| suspendBackgroundProcessing | property |
public var suspendBackgroundProcessing:Boolean = false
If true, blocks all background processing
while the effect is playing.
Background processing includes measurement, layout, and
processing responses that have arrived from the server.
The default value is false.
You are encouraged to set this property to
true in most cases, because it improves
the performance of the application.
However, the property should be set to false
if either of the following is true:
The default value is false.
| target | property |
target:Object [read-write]
The UIComponent object to which this effect is applied.
When an effect is triggered by an effect trigger,
the target property is automatically set to be
the object that triggers the effect.
public function get target():Object
public function set target(value:Object):void
| targets | property |
targets:Array [read-write]
An Array of UIComponent objects that are targets for the effect.
When the effect is playing, it performs the effect on each target
in parallel.
Setting the target property replaces all objects
in this Array.
When the targets property is set, the target
property returns the first item in this Array.
public function get targets():Array
public function set targets(value:Array):void
| Effect | () | constructor |
public function Effect(target:Object = null)Constructor.
Starting an effect is usually a three-step process:
new operator.duration.play() method
or assign the effect to a trigger.target:Object (default = null) — The Object to animate with this effect.
|
| applyValueToTarget | () | method |
protected function applyValueToTarget(target:Object, property:String, value:*, props:Object):void
Used internally by the Effect infrastructure.
If captureStartValues() has been called,
then when Flex calls the play() method, it uses this function
to set the targets back to the starting state.
The default behavior is to take the value captured
using the getValueFromTarget() method
and set it directly on the target's property. For example:
target[property] = value;
Only override this method if you need to apply
the captured values in a different way.
Note that style properties of a target are set
using a different mechanism.
Use the relevantStyles property to specify
which style properties to capture and apply.
target:Object — The effect target.
|
|
property:String — The target property.
|
|
value:* — The value of the property.
|
|
props:Object — Array of Objects, where each Array element contains a
start and end Object
for the properties that the effect is monitoring.
|
| captureStartValues | () | method |
public function captureStartValues():void
Captures the current values of the relevant properties
on the effect's targets.
Flex automatically calls the captureStartValues() method
when the effect is part of a transition.
Use this function when you want the effect to figure out the start and end values of the effect. The proper usage of this function is to use it in the following steps:
captureStartValues() method.
The effect captures the starting effect values.play() method.
The effect captures the end values.
This function populates the
EffectInstance.propertyChanges property
for each effect instance created by this effect.
Effect developers can use the propertyChanges property
to retrieve the start and end values for their effect.| createInstance | () | method |
public function createInstance(target:Object = null):IEffectInstance
Creates a single effect instance and initializes it.
Use this method instead of the play() method
to manipulate the effect instance properties
before the effect instance plays.
The effect instance is created with the type
specified in the instanceClass property.
It is then initialized using the initInstance() method.
If the instance was created by the EffectManager
(when the effect is triggered by an effect trigger),
the effect is further initialized by a call to the
EffectInstance.initEffect() method.
Calling the createInstance() method
does not play the effect.
You must call the startEffect() method
on the returned effect instance.
This function is automatically called by the
Effect.play() method.
target:Object (default = null) — Object to animate with this effect.
|
IEffectInstance — The effect instance object for the effect.
|
| createInstances | () | method |
public function createInstances(targets:Array = null):Array
Takes an Array of target objects and invokes the
createInstance() method on each target.
targets:Array (default = null) — Array of objects to animate with this effect.
|
Array —
Array of effect instance objects, one per target, for the effect.
|
| effectEndHandler | () | method |
protected function effectEndHandler(event:EffectEvent):voidCalled when an effect instance has finished playing. If you override this method, ensure that you call the super method.
Parametersevent:EffectEvent — An event object of type EffectEvent.
|
| effectStartHandler | () | method |
protected function effectStartHandler(event:EffectEvent):voidThis method is called when the effect instance starts playing. If you override this method, ensure that you call the super method.
Parametersevent:EffectEvent — An event object of type EffectEvent.
|
| end | () | method |
public function end(effectInstance:IEffectInstance = null):void
Interrupts an effect that is currently playing,
and jumps immediately to the end of the effect.
Calling this method invokes the EffectInstance.end()
method.
The effect instance dispatches an effectEnd event
when you call this method as part of ending the effect.
If you pass an effect instance as an argument, just that instance is interrupted. If no argument is passed in, all effect instances currently spawned from the effect are interrupted.
ParameterseffectInstance:IEffectInstance (default = null) — EffectInstance to terminate.
|
See also
| filterInstance | () | method |
protected function filterInstance(propChanges:Array, targ:Object):BooleanDetermines the logic for filtering out an effect instance. The CompositeEffect class overrides this method.
ParameterspropChanges:Array — The properties modified by the effect.
|
|
targ:Object — The effect target.
|
Boolean —
Returns true if the effect instance should play.
|
| getAffectedProperties | () | method |
public function getAffectedProperties():Array
Returns an Array of Strings, where each String is the name
of a property that is changed by this effect.
For example, the Move effect returns an Array that contains
"x" and "y".
Every subclass of Effect must implement this method. The method is used by the EffectManager to ensure that no two effects are trying to animate the same property of the same object at the same time.
ReturnsArray —
An Array of Strings specifying the names of the
properties modified by this effect.
|
| getValueFromTarget | () | method |
protected function getValueFromTarget(target:Object, property:String):*
Called by the captureStartValues() method to get the value
of a property from the target.
This function should only be called internally
by the effects framework.
The default behavior is to simply return target[property].
Effect developers can override this function
if you need a different behavior.
target:Object — The effect target.
|
|
property:String — The target property.
|
* — The value of the target property.
|
| initInstance | () | method |
protected function initInstance(instance:IEffectInstance):voidCopies properties of the effect to the effect instance.
Flex calls this method from the Effect.createInstance()
method; you do not have to call it yourself.
When you create a custom effect, override this method to
copy properties from the Effect class to the effect instance class.
In your override, you must call super.initInstance().
instance:IEffectInstance — The effect instance to initialize.
|
| pause | () | method |
public function pause():void
Pauses the effect until you call the resume() method.
| play | () | method |
public function play(targets:Array = null, playReversedFromEnd:Boolean = false):Array
Begins playing the effect. You typically call the end() method
before you call the play() method to ensure that any previous
instance of the effect has ended before you start a new one.
All subclasses must implement this method.
Parameterstargets:Array (default = null) — Array of target objects on which to play this effect. If this
parameter is specified, then the effect's targets property is
not used.
|
|
playReversedFromEnd:Boolean (default = false) — If true,
play the effect backwards.
|
Array —
Array of EffectInstance objects, one per target, for the effect.
|
| resume | () | method |
public function resume():void
Resumes the effect after it has been paused
by a call to the pause() method.
| reverse | () | method |
public function reverse():voidPlays the effect in reverse, if the effect is currently playing, starting from the current position of the effect.
| effectEnd | event |
mx.events.EffectEvent
mx.events.EffectEvent.EFFECT_END
Dispatched when the effect finishes playing,
either when the effect finishes playing or when the effect has
been interrupted by a call to the end() method.
The EffectEvent.EFFECT_END constant defines the value of the
type property of the event object for an
effectEnd event.
The properties of the event object have the following values:
| Property | Value |
|---|---|
bubbles | false |
cancelable | false |
currentTarget | The Object that defines the
event listener that handles the event. For example, if you use
myButton.addEventListener() to register an event listener,
myButton is the value of the currentTarget. |
effectInstance | The effect instance object for the event. |
target | The Object that dispatched the event;
it is not always the Object listening for the event.
Use the currentTarget property to always access the
Object listening for the event. |
| effectStart | event |
mx.events.EffectEvent
mx.events.EffectEvent.EFFECT_START
Dispatched when the effect starts playing.
The EffectEvent.EFFECT_START constant defines the value of the
type property of the event object for an
effectStart event.
The properties of the event object have the following values:
| Property | Value |
|---|---|
bubbles | false |
cancelable | false |
currentTarget | The Object that defines the
event listener that handles the event. For example, if you use
myButton.addEventListener() to register an event listener,
myButton is the value of the currentTarget. |
effectInstance | The effect instance object for the event. |
target | The Object that dispatched the event;
it is not always the Object listening for the event.
Use the currentTarget property to always access the
Object listening for the event. |
<?xml version="1.0"?>
<!-- Simple example to demonstrate the Effect class. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
// Event handler for the effectEnd event.
private function endEffectHandler():void {
Alert.show("Effect Ended!");
}
// Event handler for the reset button.
private function resetHandler():void {
expand.end();
img.width=30;
img.height=60;
button1.enabled=true;
}
]]>
</mx:Script>
<mx:Resize id="expand" target="{img}" widthTo="100" heightTo="200"
duration="10000" effectEnd="endEffectHandler();"/>
<mx:Panel title="Resize Effect Example" width="100%" height="100%"
paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10">
<mx:Text width="100%" color="blue"
text="Use the Button controls to control the Resize effect."/>
<mx:Image id="img" width="30" height="60"
source="@Embed(source='assets/Nokia_6630.png')"/>
<mx:ControlBar>
<mx:Button id="button1" label="Start" click="expand.play(); button1.enabled=false;"/>
<mx:Button label="Pause" click="expand.pause();"/>
<mx:Button label="Resume" click="expand.resume();"/>
<mx:Button label="Reverse" click="expand.reverse();"/>
<mx:Button label="End" click="expand.end();"/>
<mx:Button label="Reset" click="resetHandler();"/>
</mx:ControlBar>
</mx:Panel>
</mx:Application>