Flash CS3 Documentation |
|||
| ActionScript 2.0 Language Reference > ActionScript classes > Matrix (flash.geom.Matrix) > transformPoint (Matrix.transformPoint method) | |||
public transformPoint(pt:Point) : Point
Applies the geometric transformation represented by the Matrix object to the specified point.
Availability: ActionScript 1.0; Flash Player 8
pt:Point - The Point (x,y) to be transformed.
Point - The new Point object.
The following example uses the transformPoint() method to create transformedPoint from myPoint. The translate() method does have an affect on the position of transformedPoint. In the example, scale() increases the original x value by a factor of three from 50 to 150, and the translate() method increases x by 300 for a total value of 450.
import flash.geom.Matrix;
import flash.geom.Point;
var myMatrix:Matrix = new Matrix();
trace(myMatrix); // (a=1, b=0, c=0, d=1, tx=0, ty=0)
myMatrix.translate(100, 0);
trace(myMatrix); // (a=1, b=0, c=0, d=1, tx=100, ty=0)
myMatrix.scale(3, 3);
trace(myMatrix); // (a=3, b=0, c=0, d=3, tx=300, ty=0)
var myPoint:Point = new Point(50,0);
trace(myPoint); // (50, 0)
var transformedPoint:Point = myMatrix.transformPoint(myPoint);
trace(transformedPoint); // (450, 0)
var pointMc_0:MovieClip = createRectangle(10, 10, 0xFF0000);
pointMc_0._x = myPoint.x;
var pointMc_1:MovieClip = createRectangle(10, 10, 0x00FF00);
pointMc_1._x = transformedPoint.x;
function createRectangle(width:Number, height:Number, color:Number):MovieClip {
var depth:Number = this.getNextHighestDepth();
var mc:MovieClip = this.createEmptyMovieClip("mc_" + depth, depth);
mc.beginFill(color);
mc.lineTo(0, height);
mc.lineTo(width, height);
mc.lineTo(width, 0);
mc.lineTo(0, 0);
return mc;
}
Flash CS3
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/9.0/main/00001859.html