Most often, questions are asked about how to scale a DisplayObject, and the answer is usually to use a Matrix.
My question is, how to you GET the scale of a Matrix (
you have access to the matrix object's a
and d
public properties, which represent the scaling of the x-axis and y-axis respectively:
package
{
//Imports
import flash.display.Sprite;
import flash.geom.Matrix;
import flash.display.Shape;
//Class
public class Test extends Sprite
{
//Constructor
public function Test()
{
var sh:Shape = new Shape();
sh.graphics.beginFill(0xFF0000, 1.0);
sh.graphics.drawRect(0, 0, 100, 100);
sh.graphics.endFill();
var scaleMatrix:Matrix = new Matrix();
scaleMatrix.scale(4, 6);
sh.transform.matrix = scaleMatrix;
addChild(sh);
trace("Matrix X Scale: " + scaleMatrix.a, "\nMatrix Y Scale: " + scaleMatrix.d);
}
}
}
// Matrix X Scale: 4
// Matrix Y Scale: 6