fl.motion

# MotionBase - AS3 Flash

Package | fl.motion
Class | public class MotionBase
Inheritance | MotionBase Object
Subclasses | Motion

Language Version: | ActionScript 3.0

Product Version: | Flash CS3

Runtime Versions: | Flash Player 9.0.28.0, AIR 1.0

The MotionBase class stores a keyframe animation sequence that can be applied to a visual object. The animation data includes position, scale, rotation, skew, color, filters, and easing. The MotionBase class has methods for retrieving data at specific keyframe points. To get interpolated values between keyframes, use the Motion class.

View the examples

Related API Elements

Motion class
Motion XML Elements

Public Properties
Hide Inherited Public Properties
Show Inherited Public Properties

| Property | Defined By
--- | --- | ---
|  | constructor : Object A reference to the class object or constructor function for a given object instance. | Object
|  | duration : int Controls the Motion instance's length of time, measured in frames. | MotionBase
|  | is3D : Boolean Specifies whether the motion contains 3D property changes. | MotionBase
|  | keyframes : Array An array of keyframes that define the motion's behavior over time. | MotionBase

Public Methods
Hide Inherited Public Methods
Show Inherited Public Methods

| Method | Defined By
--- | --- | ---
|  | MotionBase(xml:XML = null) Constructor for MotionBase instances. | MotionBase
|  | addFilterPropertyArray(index:int, name:String, values:Array, startFrame:int = -1, endFrame:int = -1):void Modifies a filter property in all corresponding keyframes for a Motion object. | MotionBase
|  | addKeyframe(newKeyframe:KeyframeBase):void Adds a keyframe object to the Motion instance. | MotionBase
|  | addPropertyArray(name:String, values:Array, startFrame:int = -1, endFrame:int = -1):void Stores an array of values in corresponding keyframes for a declared property of the Motion class. | MotionBase
|  | getColorTransform(index:int):flash.geom:ColorTransform Retrieves an interpolated ColorTransform object at a specific time index in the Motion instance. | MotionBase
|  | getCurrentKeyframe(index:int, tweenableName:String = ""):KeyframeBase Retrieves the keyframe that is currently active at a specific frame in the Motion instance. | MotionBase
|  | getFilters(index:Number):Array Retrieves an interpolated array of filters at a specific time index in the Motion instance. | MotionBase
|  | getMatrix(index:int):Matrix Returns the Matrix object for the specified index position of the frame of animation. | MotionBase
|  | getMatrix3D(index:int):Object Returns the Matrix3D object for the specified index position of the frame of animation. | MotionBase
|  | getNextKeyframe(index:int, tweenableName:String = ""):KeyframeBase Retrieves the next keyframe after a specific frame in the Motion instance. | MotionBase
|  | getValue(index:Number, tweenableName:String):Number Retrieves the value for an animation property at a point in time. | MotionBase
|  | hasOwnProperty(name:String):Boolean Indicates whether an object has a specified property defined. | Object
|  | initFilters(filterClasses:Array, gradientSubarrayLengths:Array, startFrame:int = -1, endFrame:int = -1):void Initializes the filters list for the target object and copies the list of filters to each Keyframe instance of the Motion object. | MotionBase
|  | isPrototypeOf(theClass:Object):Boolean Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter. | Object
|  | overrideTargetTransform(scale:Boolean = true, skew:Boolean = true, rotate:Boolean = true):void | MotionBase
|  | propertyIsEnumerable(name:String):Boolean Indicates whether the specified property exists and is enumerable. | Object
|  | setPropertyIsEnumerable(name:String, isEnum:Boolean = true):void Sets the availability of a dynamic property for loop operations. | Object
|  | setValue(index:int, tweenableName:String, value:Number):void Sets the value of a specific tweenables property at a given time index in the Motion instance. | MotionBase
|  | toLocaleString():String Returns the string representation of this object, formatted according to locale-specific conventions. | Object
|  | toString():String Returns the string representation of the specified object. | Object
|  | useRotationConcat(index:int):Boolean Rotates the target object when data for the motion is supplied by the addPropertyArray() method. | MotionBase
|  | valueOf():Object Returns the primitive value of the specified object. | Object

Property Detail

### duration

property

`duration:int`

Language Version: | ActionScript 3.0

Product Version: | Flash CS3

Runtime Versions: | Flash Player 9.0.28.0, AIR 1.0

Controls the Motion instance's length of time, measured in frames. The duration cannot be less than the time occupied by the Motion instance's keyframes.

The default value is `0.`

Implementation
`public function get duration():int`
`public function set duration(value:int):void`

### is3D

property

`is3D:Boolean`

Language Version: | ActionScript 3.0

Product Version: | Flash CS3

Runtime Versions: | Flash Player 10, AIR 1.5, AIR 1.0

Specifies whether the motion contains 3D property changes. If `true`, the motion contains 3D property changes.

The default value is `false.`

Implementation
`public function get is3D():Boolean`
`public function set is3D(value:Boolean):void`

### keyframes

property

`public var keyframes:Array`

Language Version: | ActionScript 3.0

Product Version: | Flash CS3

Runtime Versions: | Flash Player 9.0.28.0, AIR 1.0

An array of keyframes that define the motion's behavior over time. This property is a sparse array, where a keyframe is placed at an index in the array that matches its own index. A motion object with keyframes at 0 and 5 has a keyframes array with a length of 6. Indices 0 and 5 in the array each contain a keyframe, and indices 1 through 4 have null values.

Constructor Detail

### MotionBase

()
Constructor

`public function MotionBase(xml:XML = null)`

Language Version: | ActionScript 3.0

Product Version: | Flash CS3

Runtime Versions: | Flash Player 9.0.28.0, AIR 1.0

Constructor for MotionBase instances. By default, one initial keyframe is created automatically, with default transform properties.

Parameters

| `xml:XML` (default = `null`)`` — Optional E4X XML object defining a Motion instance.

Method Detail

### addFilterPropertyArray

()
method

`public function addFilterPropertyArray(index:int, name:String, values:Array, startFrame:int = -1, endFrame:int = -1):void`

Language Version: | ActionScript 3.0

Product Version: | Flash CS3

Runtime Versions: | Flash Player 9.0.28.0, AIR 1.0

Modifies a filter property in all corresponding keyframes for a Motion object. Call `initFilters()` before using this method. The order of the values in the array determines the assignment of each value to the filter property for all keyframes. For each non-null value in the specified `values` array, this method finds the keyframe corresponding to the value's index position in the array, and stores the property name/value pair for the filter in the keyframe.

Parameters

| `index:int` — The zero-based index position in the array of filters.
| `name:String` — The name of the filter property to store in each keyframe.
| `values:Array` — The array of values for the property specified in the `name` parameter. Each non-null value is assigned to the filter in a keyframe that corresponds to the value's index in the array.
| `startFrame:int` (default = `-1`)``
| `endFrame:int` (default = `-1`)``

More examples

Adding filters

Related API Elements

initFilters()
flash.filters

### addKeyframe

()
method

`public function addKeyframe(newKeyframe:KeyframeBase):void`

Language Version: | ActionScript 3.0

Product Version: | Flash CS3

Runtime Versions: | Flash Player 9.0.28.0, AIR 1.0

Adds a keyframe object to the Motion instance.

Parameters

| `newKeyframe:KeyframeBase` — A keyframe object with an index property already set.

Related API Elements

fl.motion.Keyframe

### addPropertyArray

()
method

`public function addPropertyArray(name:String, values:Array, startFrame:int = -1, endFrame:int = -1):void`

Language Version: | ActionScript 3.0

Product Version: | Flash CS3

Runtime Versions: | Flash Player 9.0.28.0, AIR 1.0

Stores an array of values in corresponding keyframes for a declared property of the Motion class. The order of the values in the array determines the assignment of each value to a keyframe. For each non-null value in the given `values` array, this method finds the keyframe corresponding to the value's index position in the array, or creates a new keyframe for that index position, and stores the property name/value pair in the keyframe.

Parameters

| `name:String` — The name of the Motion class property to store in each keyframe.
| `values:Array` — The array of values for the property specified in the `name` parameter. Each non-null value is assigned to a keyframe that corresponds to the value's order in the array.
| `startFrame:int` (default = `-1`)``
| `endFrame:int` (default = `-1`)``

More examples

Describing the animation

Related API Elements

fl.motion.Motion

### getColorTransform

()
method

`public function getColorTransform(index:int):flash.geom:ColorTransform`

Language Version: | ActionScript 3.0

Product Version: | Flash CS3

Runtime Versions: | Flash Player 9.0.28.0, AIR 1.0

Retrieves an interpolated ColorTransform object at a specific time index in the Motion instance.

Parameters

| `index:int` — The time index of a frame in the Motion instance, as an integer greater than or equal to zero.

Returns

| `flash.geom:ColorTransform` — The interpolated ColorTransform object.

Related API Elements

flash.geom.ColorTransform

### getCurrentKeyframe

()
method

`public function getCurrentKeyframe(index:int, tweenableName:String = ""):KeyframeBase`

Language Version: | ActionScript 3.0

Product Version: | Flash CS3

Runtime Versions: | Flash Player 9.0.28.0, AIR 1.0

Retrieves the keyframe that is currently active at a specific frame in the Motion instance. A frame that is not a keyframe derives its values from the keyframe that preceded it.

This method can also filter values by the name of a specific tweenables property. You can find the currently active keyframe for `x`, which may not be the same as the currently active keyframe in general.

Parameters

| `index:int` — The index of a frame in the Motion instance, as an integer greater than or equal to zero.
| `tweenableName:String` (default = "``")`` — Optional name of a tweenable's property (like `"x"` or `"rotation"`).

Returns

| `KeyframeBase` — The closest matching keyframe at or before the supplied frame index.

Related API Elements

fl.motion.Tweenables

### getFilters

()
method

`public function getFilters(index:Number):Array`

Language Version: | ActionScript 3.0

Product Version: | Flash CS3

Runtime Versions: | Flash Player 9.0.28.0, AIR 1.0

Retrieves an interpolated array of filters at a specific time index in the Motion instance.

Parameters

| `index:Number` — The time index of a frame in the Motion, as an integer greater than or equal to zero.

Returns

| `Array` — The interpolated array of filters. If there are no applicable filters, returns an empty array.

Related API Elements

flash.filters

### getMatrix

()
method

`public function getMatrix(index:int):Matrix`

Language Version: | ActionScript 3.0

Product Version: | Flash CS3

Runtime Versions: | Flash Player 10, AIR 1.5, AIR 1.0

Returns the Matrix object for the specified index position of the frame of animation.

Parameters

| `index:int` — The zero-based index position of the frame of animation containing the matrix.

Returns

| `Matrix` — The Matrix object, or null value. This method can return a null value even if `MotionBase.is3D` is `false`, because other motion tween property changes can be used without a Matrix object.

Related API Elements

flash.geom.Matrix

### getMatrix3D

()
method

`public function getMatrix3D(index:int):Object`

Language Version: | ActionScript 3.0

Product Version: | Flash CS3

Runtime Versions: | Flash Player 10, AIR 1.5, AIR 1.0

Returns the Matrix3D object for the specified index position of the frame of animation.

Parameters

| `index:int` — The zero-based index position of the frame of animation containing the 3D matrix.

Returns

| `Object` — The Matrix3D object, or null value. This method can return a null value even if `MotionBase.is3D` is `true`, because other 3D motion tween property changes can be used without a Matrix3D object.

Related API Elements

flash.geom.Matrix3D

### getNextKeyframe

()
method

`public function getNextKeyframe(index:int, tweenableName:String = ""):KeyframeBase`

Language Version: | ActionScript 3.0

Product Version: | Flash CS3

Runtime Versions: | Flash Player 9.0.28.0, AIR 1.0

Retrieves the next keyframe after a specific frame in the Motion instance. If a frame is not a keyframe, and is in the middle of a tween, this method derives its values from both the preceding keyframe and the following keyframe.

This method also allows you to filter by the name of a specific tweenables property to find the next keyframe for a property, which might not be the same as the next keyframe in general.

Parameters

| `index:int` — The index of a frame in the Motion instance, as an integer greater than or equal to zero.
| `tweenableName:String` (default = "``")`` — Optional name of a tweenable's property (like `"x"` or `"rotation"`).

Returns

| `KeyframeBase` — The closest matching keyframe after the supplied frame index.

Related API Elements

fl.motion.Tweenables

### getValue

()
method

`public function getValue(index:Number, tweenableName:String):Number`

Language Version: | ActionScript 3.0

Product Version: | Flash CS3

Runtime Versions: | Flash Player 9.0.28.0, AIR 1.0

Retrieves the value for an animation property at a point in time.

Parameters

| `index:Number` — The time index of a frame in the Motion instance, as an integer greater than or equal to zero.
| `tweenableName:String` — The name of a tweenable's property (like `"x"` or `"rotation"`).

Returns

| `Number` — The number value for the property specified in the `tweenableName` parameter.

Related API Elements

fl.motion.Tweenables

### initFilters

()
method

`public function initFilters(filterClasses:Array, gradientSubarrayLengths:Array, startFrame:int = -1, endFrame:int = -1):void`

Language Version: | ActionScript 3.0

Product Version: | Flash CS3

Runtime Versions: | Flash Player 9.0.28.0, AIR 1.0

Initializes the filters list for the target object and copies the list of filters to each Keyframe instance of the Motion object.

Parameters

| `filterClasses:Array` — An array of filter classes. Each item in the array is the fully qualified class name (in String form) for the filter type occupying that index.
| `gradientSubarrayLengths:Array` — An array of numbers containing a value for every filter that will be in the filters list for the motion (every class name in the `filterClasses` array). A value in the `gradientSubarrayLengths` array is only used if the filter class entry at the same index position in the `filterClasses` array is GradientGlowFilter or GradientBevelFilter. The corresponding value in the `gradientSubarrayLengths` array is a number that determines the length for the arrays that initialize the `colors`, `alphas`, and `ratios` parameters for the GradientGlowFilter and GradientBevelFilter constructor functions.
| `startFrame:int` (default = `-1`)``
| `endFrame:int` (default = `-1`)``

More examples

Adding filters

Related API Elements

flash.filters
flash.filters.GradientGlowFilter
flash.filters.GradientBevelFilter

### overrideTargetTransform

()
method

`public function overrideTargetTransform(scale:Boolean = true, skew:Boolean = true, rotate:Boolean = true):void`

Parameters

| `scale:Boolean` (default = `true`)``
| `skew:Boolean` (default = `true`)``
| `rotate:Boolean` (default = `true`)``

### setValue

()
method

`public function setValue(index:int, tweenableName:String, value:Number):void`

Language Version: | ActionScript 3.0

Product Version: | Flash CS3

Runtime Versions: | Flash Player 9.0.28.0, AIR 1.0

Sets the value of a specific tweenables property at a given time index in the Motion instance. If a keyframe doesn't exist at the index, one is created automatically.

Parameters

| `index:int` — The time index of a frame in the Motion instance, as an integer greater than zero. If the index is zero, no change is made. Transformation properties are relative to the starting transformation values of the target object, the values for the first frame (zero index value) are always default values and should not be changed.
| `tweenableName:String` — The name of a tweenable's property as a string (like `"x"` or `"rotation"`).
| `value:Number` — The new value of the tweenable property.

Related API Elements

fl.motion.Tweenables

### useRotationConcat

()
method

`public function useRotationConcat(index:int):Boolean`

Language Version: | ActionScript 3.0

Product Version: | Flash CS3

Runtime Versions: | Flash Player 10, AIR 1.5, AIR 1.0

Rotates the target object when data for the motion is supplied by the `addPropertyArray()` method.

Parameters

| `index:int` — The index position of the frame of animation.

Returns

| `Boolean` — Indicates whether the target object will rotate using the stored property from `KeyframeBase.rotationConcat`.

Related API Elements

addPropertyArray()
fl.motion.KeyframeBase.rotationConcat
Examples How to use this example
MotionBaseExample.as
This example shows how to animate a sprite with the use of the MotionBase and AnimatorFactory classes. A MotionBase object is assigned arrays of x and y coordinates, and is then used to create an AnimatorFactory object. The AnimatorFactory is finally targeted to a sprite, in the form of a filled rectangle.
Copy

    package
    {
         import flash.display.MovieClip;
         import flash.display.Sprite;
         import fl.motion.AnimatorFactory;
         import fl.motion.MotionBase;
         import flash.geom.Point;

         public class  MotionBaseExample extends MovieClip
         {
              private var motionBase:MotionBase;
              private var animFactory:AnimatorFactory;
              private var size:uint    = 100;
              private var bgColor:uint = 0xFFCC00;

              public function MotionBaseExample():void
              {
                   var boxObj:sprite = new Sprite();
                   boxObj.graphics.beginFill(bgColor);
                   boxObj.graphics.drawRect(0, 0, size, size);
                   boxObj.graphics.endFill();
                   addChild(boxObj);

                   motionBase = new MotionBase();
                   motionBase.duration = 20;
                   motionBase.addPropertyArray("x",[0,50,95,134,169,199,225,247,265,280]);
                   motionBase.addPropertyArray("y",[0,1,0,4,12,21,32,44,52,38]);
                   animFactory = new AnimatorFactory(motionBase);
                   animFactory.transformationPoint = new Point(2, 2);
                   animFactory.addTarget(boxObj, 0);
              }
         }
    }

© 2015 Adobe Systems Incorporated. All rights reserved.
Mon Apr 10 2017, 12:28 PM -07:00