createBox (Matrix.createBox method)

public createBox(scaleX:Number, scaleY:Number, [rotation:Number], [tx:Number], [ty:Number]) : Void

Includes parameters for scaling, rotation, and translation. When applied to a matrix it sets the matrix's values based on those parameters.

Using the createBox() method lets you obtain the same matrix as you would if you were to apply the identity(), rotate(), scale(), and translate() methods in succession. For example, mat1.createBox(2,2,Math.PI/5, 100, 100) has the same effect as the following:

 import flash.geom.Matrix;

 var mat1:Matrix = new Matrix();
 mat1.identity();
 mat1.rotate(Math.PI/4);
 mat1.scale(2,2);
 mat1.translate(10,20);

Availability: ActionScript 1.0; Flash Player 8

Parameters

scaleX:Number - The factor by which to scale horizontally.

scaleY:Number - The factor by which scale vertically.

rotation:Number [optional] - The amount to rotate, in radians. The default value is 0.

tx:Number [optional] - The number of pixels to translate (move) to the right along the x axis. The default value is 0.

ty:Number [optional] - The number of pixels to translate (move) down along the y axis. The default value is 0.

Example

The following example sets the scaleX, scaleY scale, rotation, x location, and y location of myMatrix by calling its createBox() method.

import flash.geom.Matrix;
import flash.geom.Transform;

var myMatrix:Matrix = new Matrix();
trace(myMatrix.toString()); // (a=1, b=0, c=0, d=1, tx=0, ty=0)

myMatrix.createBox(1, 2, Math.PI/4, 100, 200);
trace(myMatrix.toString()); // (a=0.707106781186548, b=1.41421356237309, c=-0.707106781186547, d=1.4142135623731, tx=100, ty=200)

var rectangleMc:MovieClip = createRectangle(20, 80, 0xFF0000);
var rectangleTrans:Transform = new Transform(rectangleMc);
rectangleTrans.matrix = myMatrix;

See also

beginBitmapFill (MovieClip.beginBitmapFill method)


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/00001849.html