1 package flare.animate.interpolate
3 import flash.geom.Point;
6 * Interpolator for <code>flash.geom.Point</code> values.
8 public class PointInterpolator extends Interpolator
10 private var _startX:Number, _startY:Number;
11 private var _rangeX:Number, _rangeY:Number;
12 private var _cur:Point;
15 * Creates a new PointInterpolator.
16 * @param target the object whose property is being interpolated
17 * @param property the property to interpolate
18 * @param start the starting point value to interpolate from
19 * @param end the target point value to interpolate to
21 public function PointInterpolator(target:Object, property:String,
22 start:Object, end:Object)
24 super(target, property, start, end);
28 * Initializes this interpolator.
29 * @param start the starting value of the interpolation
30 * @param end the target value of the interpolation
32 protected override function init(start:Object, end:Object) : void
34 var e:Point = Point(end), s:Point = Point(start);
35 if (_cur == null || _cur == s || _cur == e)
40 _rangeX = e.x - _startX;
41 _rangeY = e.y - _startY;
45 * Calculate and set an interpolated property value.
46 * @param f the interpolation fraction (typically between 0 and 1)
48 public override function interpolate(f:Number) : void
50 _cur.x = _startX + f*_rangeX;
51 _cur.y = _startY + f*_rangeY;
52 _prop.setValue(_target, _cur);
55 } // end of class PointInterpolator