Packagefl.motion
Classpublic class Animator
InheritanceAnimator Inheritance EventDispatcher Inheritance Object

Language Version : ActionScript 3.0
Player Version : Flash Player 9.0.28.0

The Animator class applies an XML description of a motion tween to a display object. The properties and methods of the Animator class control the playback of the motion, and Flash Player broadcasts events in response to changes in the motion's status. The Animator class is primarily used by the Copy Motion as ActionScript command in Flash CS3. You can then edit the ActionScript using the application programming interface (API) or construct your own custom animation.

If you plan to call methods of the Animator class within a function, declare the Animator instance outside of the function so the scope of the object is not restricted to the function itself. If you declare the instance within a function, Flash Player deletes the Animator instance at the end of the function as part of Flash Player's routine "garbage collection" and the target object will not animate.

Default MXML Propertymotion

See also

Motion XML Elements


Public Properties
 PropertyDefined By
  autoRewind : Boolean = false
Sets the animation to restart after it finishes.
Animator
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
  isPlaying : Boolean
[read-only] Indicates whether the animation is currently playing.
Animator
  motion : Motion
The object that contains the motion tween properties for the animation.
Animator
  orientToPath : Boolean = false
Sets the position of the display object along the motion path.
Animator
  positionMatrix : Matrix
The Matrix object that applies an overall transformation to the motion path.
Animator
 Inheritedprototype : Object
[static] A reference to the prototype object of a class or function object.
Object
  repeatCount : int = 1
Number of times to repeat the animation.
Animator
  target : DisplayObject
The display object being animated.
Animator
  time : int
A zero-based integer that indicates and controls the time in the current animation.
Animator
  transformationPoint : Point
The point of reference for rotating or scaling a display object.
Animator
Public Methods
 MethodDefined By
  
Animator(xml:XML = null, target:DisplayObject = null)
Creates an Animator object to apply the XML-based motion tween description to a display object.
Animator
 Inherited
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
 Inherited
Dispatches an event into the event flow.
EventDispatcher
  
end():void
Stops the animation and Flash Player goes immediately to the last frame in the animation sequence.
Animator
  
fromXMLString(xmlString:String, target:DisplayObject = null):Animator
[static] Creates an Animator object from a string of XML.
Animator
 Inherited
Checks whether the EventDispatcher object has any listeners registered for a specific type of event.
EventDispatcher
 Inherited
Indicates whether an object has a specified property defined.
Object
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
  
Advances Flash Player to the next frame in the animation sequence.
Animator
  
Pauses the animation until you call the resume() method.
Animator
  
Begins the animation.
Animator
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Removes a listener from the EventDispatcher object.
EventDispatcher
  
Resumes the animation after it has been paused by the pause() method.
Animator
  
Sets Flash Player to the first frame of the animation.
Animator
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
  
Stops the animation and Flash Player goes back to the first frame in the animation sequence.
Animator
 Inherited
Returns the string representation of the specified object.
Object
 Inherited
Returns the primitive value of the specified object.
Object
 Inherited
Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type.
EventDispatcher
Events
 Event Summary Defined By
 Inherited Dispatched when Flash Player or an AIR application gains operating system focus and becomes active.EventDispatcher
 Inherited Dispatched when Flash Player or an AIR application loses operating system focus and is becoming inactive.EventDispatcher
   Dispatched when the motion finishes playing, either when it reaches the end, or when the motion has been interrupted by a call to the stop() or end() methods.Animator
   Dispatched when the motion starts playing.Animator
   Dispatched when the motion has changed and the screen has been updated.Animator
   Dispatched when the Animator's time value has changed, but the screen has not yet been updated (i.e., the motionUpdate event).Animator
Property Detail
autoRewindproperty
public var autoRewind:Boolean = false

Language Version : ActionScript 3.0
Player Version : Flash Player 9.0.28.0

Sets the animation to restart after it finishes.

isPlayingproperty 
isPlaying:Boolean  [read-only]

Language Version : ActionScript 3.0
Player Version : Flash Player 9.0.28.0

Indicates whether the animation is currently playing.


Implementation
    public function get isPlaying():Boolean
motionproperty 
motion:Motion  [read-write]

Language Version : ActionScript 3.0
Player Version : Flash Player 9.0.28.0

The object that contains the motion tween properties for the animation.


Implementation
    public function get motion():Motion
    public function set motion(value:Motion):void
orientToPathproperty 
public var orientToPath:Boolean = false

Language Version : ActionScript 3.0
Player Version : Flash Player 9.0.28.0

Sets the position of the display object along the motion path. If set to true the baseline of the display object orients to the motion path; otherwise the registration point orients to the motion path.

positionMatrixproperty 
public var positionMatrix:Matrix

Language Version : ActionScript 3.0
Player Version : Flash Player 9.0.28.0

The Matrix object that applies an overall transformation to the motion path. This matrix allows the path to be shifted, scaled, skewed or rotated, without changing the appearance of the display object.

repeatCountproperty 
public var repeatCount:int = 1

Language Version : ActionScript 3.0
Player Version : Flash Player 9.0.28.0

Number of times to repeat the animation. Possible values are any integer greater than or equal to 0. A value of 1 means to play the animation once. A value of 0 means to play the animation indefinitely until explicitly stopped (by a call to the end() method, for example).

The default value is 1.

See also

targetproperty 
target:DisplayObject  [read-write]

Language Version : ActionScript 3.0
Player Version : Flash Player 9.0.28.0

The display object being animated. Any subclass of flash.display.DisplayObject can be used, such as a MovieClip, Sprite, or Bitmap.


Implementation
    public function get target():DisplayObject
    public function set target(value:DisplayObject):void

See also

timeproperty 
time:int  [read-write]

Language Version : ActionScript 3.0
Player Version : Flash Player 9.0.28.0

A zero-based integer that indicates and controls the time in the current animation. At the animation's first frame time is 0. If the animation has a duration of 10 frames, at the last frame time is 9.


Implementation
    public function get time():int
    public function set time(value:int):void
transformationPointproperty 
public var transformationPoint:Point

Language Version : ActionScript 3.0
Player Version : Flash Player 9.0.28.0

The point of reference for rotating or scaling a display object. The transformation point is relative to the display object's bounding box. The point's coordinates must be scaled to a 1px x 1px box, where (1, 1) is the object's lower-right corner, and (0, 0) is the object's upper-left corner.

Constructor Detail
Animator()Constructor
public function Animator(xml:XML = null, target:DisplayObject = null)

Language Version : ActionScript 3.0
Player Version : Flash Player 9.0.28.0

Creates an Animator object to apply the XML-based motion tween description to a display object.

Parameters
xml:XML (default = null) — An E4X object containing an XML-based motion tween description.
 
target:DisplayObject (default = null) — The display object using the motion tween.

See also

Method Detail
end()method
public function end():void

Language Version : ActionScript 3.0
Player Version : Flash Player 9.0.28.0

Stops the animation and Flash Player goes immediately to the last frame in the animation sequence. If the autoRewind property is set to true, Flash Player goes to the first frame in the animation sequence.

See also

fromXMLString()method 
public static function fromXMLString(xmlString:String, target:DisplayObject = null):Animator

Language Version : ActionScript 3.0
Player Version : Flash Player 9.0.28.0

Creates an Animator object from a string of XML. This method is an alternative to using the Animator constructor, which accepts an E4X object instead.

Parameters

xmlString:String — A string of XML describing the motion tween.
 
target:DisplayObject (default = null) — The display object using the motion tween.

Returns
Animator — An Animator instance that applies the specified xmlString to the specified target.

See also

nextFrame()method 
public function nextFrame():void

Language Version : ActionScript 3.0
Player Version : Flash Player 9.0.28.0

Advances Flash Player to the next frame in the animation sequence.

pause()method 
public function pause():void

Language Version : ActionScript 3.0
Player Version : Flash Player 9.0.28.0

Pauses the animation until you call the resume() method.

See also

play()method 
public function play():void

Language Version : ActionScript 3.0
Player Version : Flash Player 9.0.28.0

Begins the animation. Call the end() method before you call the play() method to ensure that any previous instance of the animation has ended before you start a new one.

See also

resume()method 
public function resume():void

Language Version : ActionScript 3.0
Player Version : Flash Player 9.0.28.0

Resumes the animation after it has been paused by the pause() method.

See also

rewind()method 
public function rewind():void

Language Version : ActionScript 3.0
Player Version : Flash Player 9.0.28.0

Sets Flash Player to the first frame of the animation. If the animation was playing, it continues playing from the first frame. If the animation was stopped, it remains stopped at the first frame.

stop()method 
public function stop():void

Language Version : ActionScript 3.0
Player Version : Flash Player 9.0.28.0

Stops the animation and Flash Player goes back to the first frame in the animation sequence.

See also

Event Detail
motionEnd Event
Event Object Type: fl.motion.MotionEvent
MotionEvent.type property = fl.motion.MotionEvent.MOTION_END

Language Version : ActionScript 3.0
Player Version : Flash Player 9.0.28.0

Dispatched when the motion finishes playing, either when it reaches the end, or when the motion has been interrupted by a call to the stop() or end() methods.

Indicates that the motion has stopped, whether by an explicit call to Animator.stop() or Animator.end(), or by reaching the end of the Motion instance.

The properties of the event object have the following values:

PropertyValue
bubblesfalse
cancelablefalse
currentTargetThe 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.
targetThe 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.
motionStart Event  
Event Object Type: fl.motion.MotionEvent
MotionEvent.type property = fl.motion.MotionEvent.MOTION_START

Language Version : ActionScript 3.0
Player Version : Flash Player 9.0.28.0

Dispatched when the motion starts playing.

Indicates that the Motion instance has started playing.

The properties of the event object have the following values:

PropertyValue
bubblesfalse
cancelablefalse
currentTargetThe 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.
targetThe 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.
motionUpdate Event  
Event Object Type: fl.motion.MotionEvent
MotionEvent.type property = fl.motion.MotionEvent.MOTION_UPDATE

Language Version : ActionScript 3.0
Player Version : Flash Player 9.0.28.0

Dispatched when the motion has changed and the screen has been updated.

Indicates that the Motion instance has changed and the screen has been updated.

The properties of the event object have the following values:

PropertyValue
bubblesfalse
cancelablefalse
currentTargetThe 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.
targetThe 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.
timeChange Event  
Event Object Type: fl.motion.MotionEvent
MotionEvent.type property = fl.motion.MotionEvent.TIME_CHANGE

Language Version : ActionScript 3.0
Player Version : Flash Player 9.0.28.0

Dispatched when the Animator's time value has changed, but the screen has not yet been updated (i.e., the motionUpdate event).

Indicates that the Animator instance's time value has changed, but the screen has not yet been updated (Flash Player has not dispatched the motionUpdate event).

The properties of the event object have the following values:

PropertyValue
bubblesfalse
cancelablefalse
currentTargetThe 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.
targetThe 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.