User Guide

Example: Applying a matrix transformation to a display object 431
The skew() method
The skew() method skews the matrix by adjusting the b and c properties of the matrix. An
optional parameter,
unit, determines the units used to define the skew angle, and if necessary,
the method converts the
angle value to radians:
if (unit == "degrees")
{
angle = Math.PI * 2 * angle / 360;
}
if (unit == "gradients")
{
angle = Math.PI * 2 * angle / 100;
}
A skewMatrix Matrix object is created and adjusted to apply the skew transformation.
Initially, it is the identity matrix, as follows:
var skewMatrix:Matrix = new Matrix();
The skewSide parameter determines the side to which the skew is applied. If it is set to
"right", the following code sets the b property of the matrix:
skewMatrix.b = Math.tan(angle);
Otherwise, the bottom side is skewed by adjusting the c property of the Matrix, as follows:
skewMatrix.c = Math.tan(angle);
The resulting skew is then applied to the existing matrix by concatenating the two matrixes, as
the following example shows:
sourceMatrix.concat(skewMatrix);
return sourceMatrix;
The scale() method
As the following example shows, the scale() method first adjusts the scale factor if it is
provided as a percentage, and then uses the
scale() method of the matrix object:
if (percent)
{
xScale = xScale / 100;
yScale = yScale / 100;
}
sourceMatrix.scale(xScale, yScale);
return sourceMatrix;