Matrix object

 < Day Day Up > 

Availability

Flash MX 2004.

Description

The Matrix object represents a transformation matrix.

Property summary for the Matrix object

The following properties are available for the Matrix object:

Property

Description

matrix.a

A floating-point value that specifies the (0,0) element in the transformation matrix.

matrix.b

A floating-point value that specifies the (0,1) element in the matrix.

matrix.c

A floating-point value that specifies the (1,0) element in the matrix.

matrix.d

A floating-point value that specifies the (1,1) element in the matrix.

matrix.tx

A floating-point value that specifies the x-axis location of a symbol's registration point or the center of a shape.

matrix.ty

A floating-point value that specifies the y-axis location of a symbol's registration point or the center of a shape.


matrix.a

Availability

Flash MX 2004.

Usage

matrix.a

Description

Property; a floating-point value that specifies the (0,0) element in the transformation matrix. This value represents the scale factor of the object's x-axis.

Example

The a and d properties in a matrix represent scaling. In the following example, the values are set to 2 and 3, respectively, to scale the selected object to two times its width and three times its height:

var mat = fl.getDocumentDOM().selection[0].matrix; mat.a = 2; mat.d = 3; fl.getDocumentDOM().selection[0].matrix = mat;

You can rotate an object by setting the a, b, c, and d matrix properties relative to one another, where a = d and b = -c. For example, values of 0.5, 0.8, -0.8, and 0.5 rotate the object 60°:

var mat = fl.getDocumentDOM().selection[0].matrix; mat.a = 0.5; mat.b = 0.8; mat.c = 0.8*(-1); mat.d = 0.5; fl.getDocumentDOM().selection[0].matrix = mat;

You can set a = d = 1 and c = b = 0 to reset the object back to its original shape.

matrix.b

Availability

Flash MX 2004.

Usage

matrix.b

Description

Property; a floating-point value that specifies the (0,1) element in the matrix. This value represents the vertical skew of a shape; it causes Flash to move the shape's right edge along the vertical axis.

The matrix.b and matrix.c properties in a matrix represent skewing (see matrix.c).

Example

In the following example, you can set b and c to -1 and 0, respectively; these settings skew the object at a 45° vertical angle:

var mat = fl.getDocumentDOM().selection[0].matrix; mat.b = -1; mat.c = 0; fl.getDocumentDOM().selection[0].matrix = mat;

To skew the object back to its original shape, you can set b and c to 0.

See also the matrix.a example.

matrix.c

Availability

Flash MX 2004.

Usage

matrix.c

Description

Property; a floating-point value that specifies the (1,0) element in the matrix. This value causes Flash to skew the object by moving its bottom edge along a horizontal axis.

The matrix.b and matrix.c properties in a matrix represent skewing.

Example

See the matrix.b example.

matrix.d

Availability

Flash MX 2004.

Usage

matrix.d

Description

Property; a floating-point value that specifies the (1,1) element in the matrix. This value represents the scale factor of the object's y-axis.

Example

See the matrix.a example.

matrix.tx

Availability

Flash MX 2004.

Usage

matrix.tx

Description

Property; a floating-point value that specifies the x-axis location of a symbol's registration point or the center of a shape. It defines the x translation of the transformation.

You can move an object by setting the matrix.tx and matrix.ty properties (see matrix.ty).

Example

In the following example, setting tx and ty to 0 moves the registration point of the object to point 0,0 in the document:

var mat = fl.getDocumentDOM().selection[0].matrix; mat.tx = 0; mat.ty = 0; fl.getDocumentDOM().selection[0].matrix = mat;

matrix.ty

Availability

Flash MX 2004.

Usage

matrix.ty

Description

Property; a floating-point value that specifies the y-axis location of a symbol's registration point or the center of a shape. It defines the y translation of the transformation.

You can move an object by setting the matrix.tx and matrix.ty properties.

Example

See the matrix.tx example.

     < Day Day Up > 


    Developing Extensions for Macromedia Flash 8
    Developing Extensions for Macromedia Flash 8
    ISBN: 032139416X
    EAN: 2147483647
    Year: 2005
    Pages: 81

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net