Math object

 < Day Day Up > 

Availability

Flash MX 2004.

Description

The Math object is available as a read-only property of the flash object; see fl.Math. This object provides methods that perform common mathematical operations.

Method summary for the Math object

The following methods are available for the Math object:

Method

Description

Math.concatMatrix()

Performs a matrix concatenation and returns the result.

Math.invertMatrix()

Returns the inverse of the specified matrix.

Math.pointDistance()

Computes the distance between two points.


Math.concatMatrix()

Availability

Flash MX 2004.

Usage

Math.concatMatrix(mat1, mat2)

Parameters

mat1 and mat2 Specify the Matrix objects to be concatenated (see Matrix object). Each parameter must be an object with fields a, b, c, d, tx, and ty.

Returns

A concatenated object matrix.

Description

Method; performs a matrix concatenation and returns the result.

Example

The following example stores the currently selected object in the elt variable, multiplies the object matrix by the view matrix, and stores that value in the mat variable:

var elt = fl.getDocumentDOM().selection[0]; var mat = fl.Math.concatMatrix( elt.matrix , fl.getDocumentDOM().viewMatrix   );

Math.invertMatrix()

Availability

Flash MX 2004.

Usage

Math.invertMatrix(mat)

Parameters

mat Indicates the Matrix object to invert (see Matrix object). It must have the following fields: a, b, c, d, tx, and ty.

Returns

A Matrix object that is the inverse of the original matrix.

Description

Method; returns the inverse of the specified matrix.

Example

The following example stores the currently selected object in the elt variable, assigns that matrix to the mat variable, and stores the inverse of the matrix in the inv variable:

var elt = fl.getDocumentDOM().selection[0]; var mat = elt.matrix; var inv = fl.Math.invertMatrix( mat );

Math.pointDistance()

Availability

Flash MX 2004.

Usage

Math.pointDistance(pt1, pt2)

Parameters

pt1 and pt2 Specify the points between which distance is measured.

Returns

A floating-point value that represents the distance between the points.

Description

Method; computes the distance between two points.

Example

The following example stores the value for the distance between pt1 and pt2 in the dist variable:

var pt1 = {x:10, y:20} var pt2 = {x:100, y:200} var dist = fl.Math.pointDistance(pt1, pt2);

     < 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