Flash CS3 Documentation |
|||
| ActionScript 2.0 Language Reference > ActionScript classes > MovieClip > transform (MovieClip.transform property) | |||
public transform : Transform
An object with properties pertaining to a movie clip's matrix, color transform, and pixel bounds. The specific properties matrix, colorTransform, and three read-only properties (concatenatedMatrix, concatenatedColorTransform, and pixelBounds) are described in the entry for the Transform class.
Each of the transform object's properties is itself an object. This is important because the only way to set new values for the matrix or colorTransform objects is to create an object and copy that object into the transform.matrix or transform.colorTransform property.
For example, to increase the tx value of a movie clip's matrix, you must make a copy of the entire matrix object, modify the tx property of the new object, and then copy the new object into the matrix property of the transform object:
var myMatrix:Object = myDisplayObject.transform.matrix; myMatrix.tx += 10; myDisplayObject.transform.matrix = myMatrix;
You cannot directly set the tx property. The following code has no effect on myDisplayObject: myDisplayObject.transform.matrix.tx += 10;
You can also copy an entire transform object and assign it to another movie clip's transform property. For example, the following code copies the entire transform object from myOldDisplayObj to myNewDisplayObj:
myNewDisplayObj.transform = myOldDisplayObj.transform;
The new movie clip, myNewDisplayObj, now has the same values for its matrix, color transform, and pixel bounds as the old movie clip, myOldDisplayObj.
Availability: ActionScript 1.0; Flash Player 8
The following example shows how to use a movie clip's transform property to access and modify a movie clip's location by using Matrix positioning.
import flash.geom.Matrix;
var rect:MovieClip = createRectangle(20, 80, 0xFF0000);
var translateMatrix:Matrix = new Matrix();
translateMatrix.translate(10, 0);
rect.onPress = function() {
var tmpMatrix:Matrix = this.transform.matrix;
tmpMatrix.concat(translateMatrix);
this.transform.matrix = tmpMatrix;
}
function createRectangle(width:Number, height:Number, color:Number, scope:MovieClip):MovieClip {
scope = (scope == undefined) ? this : scope;
var depth:Number = scope.getNextHighestDepth();
var mc:MovieClip = scope.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;
}
If your SWF file includes a version 2 component, use the version 2 components' DepthManager class instead of the MovieClip.getNextHighestDepth() method, which is used in this example.
Transform (flash.geom.Transform)
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/00001981.html