Math.approach(number,dest,factor) +
Top  Previous  Next


SWiSH Player Support
SWF4 or later - Supported Internally

Syntax
Math.approach(number, dest, factor)

Arguments
All numeric numbers or expressions.
number:Current position (x or y coordinate)
dest: Desired position (x or y coordinate)
factor: Amount to approach dest.


Returns
A number, the new current position.

Description
Use to calculate 'easing' amount in scripted moves.
Calculated function is ((number - dest) * factor + dest)
If 0 < factor < 1, Object moves towards dest, slowing as it approaches.
if 1 < factor Object moves away from dest, accelerating as it leaves.

Sample
In subsequent Frames, move Object towards X = 10 by 5% each Frame

onEnterFrame() {
    this._X = math.approach(this._X, 10, 0.95);
}


Flash MX Differences
This function is not implemented in Flash MX.