View comments | RSS feed

interpolate (Point.interpolate method)

public static interpolate(pt1:Point, pt2:Point, f:Number) : Point

Determines a point between two specified points. The parameter f determines where the new interpolated point is located relative to the two end points specified by parameters pt1 and pt2. The closer parameter f is to 1.0, the closer the interpolated point will be to the first point (parameter pt1). The closer parameter f is to 0, the closer the interpolated point will be to the second point (parameter pt2).

Availability: ActionScript 1.0; Flash Player 8

Parameters

pt1:flash.geom.Point - The first point.

pt2:flash.geom.Point - The second point.

f:Number - The level of interpolation between the two points. Indicates where the new point will be, along the line between pt1 and pt2. If f=1, pt1 is returned; if f=0, pt2 is returned.

Returns

flash.geom.Point - The new, interpolated point.

Example

The following example locates the interpolated point (interpolatedPoint) half way (50%) between point_1 and point_2.

import flash.geom.Point;
var point_1:Point = new Point(-100, -100);
var point_2:Point = new Point(50, 50);
var interpolatedPoint:Point = Point.interpolate(point_1, point_2, .5);
trace(interpolatedPoint.toString()); // (x=-25, y=-25)

Version 8

Comments


No screen name said on Aug 5, 2006 at 10:08 AM :
This function appears functioning in reverse as the following example illustrates:

iimport flash.geom.Point;

var p1:Point = new Point(0,0);
var p2:Point = new Point(10,10);
var f:Number = 1;

var p3:Point = Point.interpolate(p1,p2,f);
trace(p3); // (x=0, y=0)
Craig Grummitt said on Oct 9, 2006 at 5:15 PM :
i think it should be 'pointed' out here that flash documentation says the opposite to livedocs and livedocs is correct.
flash docs - "If f=0, pt1 is returned; if f=1, pt2 is returned."
flash livedocs - "If f=1, pt1 is returned; if f=0, pt2 is returned."

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/8/main/00002598.html