Packageflash.geom
Classpublic class Transform
InheritanceTransform Inheritance Object

The Transform class collects data about color transformations and coordinate transformations that are applied to a display object. Apply transformations by creating a new Matrix and/or a new ColorTransform and setting the appropriate properties of the transform property of a display object.

View the examples

See also

flash.display.DisplayObject.transform
flash.geom.ColorTransform
flash.geom.Matrix


Public Properties
 PropertyDefined By
  colorTransform : ColorTransform
A ColorTransform object containing values that universally adjust the colors in the display object.
Transform
  concatenatedColorTransform : ColorTransform
[read-only] A ColorTransform object representing the combined color transformations applied to the display object and all of its parent objects, back to the root level.
Transform
  concatenatedMatrix : Matrix
[read-only] A Matrix object representing the combined transformation matrixes of the display object and all of its parent objects, back to the root level.
Transform
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
  matrix : Matrix
A Matrix object containing values that affect the scaling, rotation, and translation of the display object.
Transform
  pixelBounds : Rectangle
[read-only] A Rectangle object that defines the bounding rectangle of the display object on the Stage.
Transform
 Inheritedprototype : Object
[static] A reference to the prototype object of a class or function object.
Object
Public Methods
 MethodDefined By
 Inherited
Indicates whether an object has a specified property defined.
Object
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
 Inherited
Returns the string representation of the specified object.
Object
 Inherited
Returns the primitive value of the specified object.
Object
Property Detail
colorTransformproperty
colorTransform:ColorTransform  [read-write]

A ColorTransform object containing values that universally adjust the colors in the display object.


Implementation
    public function get colorTransform():ColorTransform
    public function set colorTransform(value:ColorTransform):void

Throws
TypeError — The colorTransform is null when being set

See also

concatenatedColorTransformproperty 
concatenatedColorTransform:ColorTransform  [read-only]

A ColorTransform object representing the combined color transformations applied to the display object and all of its parent objects, back to the root level. If different color transformations have been applied at different levels, all of those transformations are concatenated into one ColorTransform object for this property.


Implementation
    public function get concatenatedColorTransform():ColorTransform

See also

concatenatedMatrixproperty 
concatenatedMatrix:Matrix  [read-only]

A Matrix object representing the combined transformation matrixes of the display object and all of its parent objects, back to the root level. If different transformation matrixes have been applied at different levels, all of those matrixes are concatenated into one matrix for this property.


Implementation
    public function get concatenatedMatrix():Matrix
matrixproperty 
matrix:Matrix  [read-write]

A Matrix object containing values that affect the scaling, rotation, and translation of the display object.


Implementation
    public function get matrix():Matrix
    public function set matrix(value:Matrix):void

Throws
TypeError — The matrix is null when being set

See also

pixelBoundsproperty 
pixelBounds:Rectangle  [read-only]

A Rectangle object that defines the bounding rectangle of the display object on the Stage.


Implementation
    public function get pixelBounds():Rectangle
Examples How to use examples
TransformExample.as

The following example uses the TransformExample class to skew the bottom side of a square sprite filled with a gradient pattern. Each time the user clicks the square, the application transforms the sprite, by skewing it. This is accomplished with the following steps:
  1. The TransformExample() constructor creates a new sprite object target.
  2. The TransformExample() constructor calls the draw() method, which draws a gradient square in the sprite.
  3. The TransformExample() constructor adds a click event listener for the sprite, which is handled by the clickHandler() method.
  4. The clickHandler() method creates a new Matrix object, skewMatrix, set to apply a skew affect. Another matrix, tempMatrix, is assigned to the current transformation matrix of the sprite, and then it is combined with the skewMatrix using the concat() method. This matrix is assigned to the assigned to the transform.matrix property of the square sprite. Each time the user clicks the square, the call to the clickHandler() modifies the shape of the square, by skewing it.
  5. Additionally, the clickHandler() method creates a new ColorTransform object. The redOffset property of the new ColorTransform is set to the current value of redOffset and incremented by 25. Likewise, the blueOffset property is decremented by 25. With each click, the colors of the sprite will change.
package {
    import flash.display.Sprite;
    import flash.display.GradientType;
    import flash.geom.Matrix;
    import flash.geom.ColorTransform;
    import flash.events.MouseEvent;

    public class TransformExample extends Sprite {
        public function TransformExample() { 
            var target:Sprite = new Sprite();
            draw(target);
            addChild(target);
            target.useHandCursor = true;
            target.buttonMode = true;
            target.addEventListener(MouseEvent.CLICK, clickHandler)
        }
        public function draw(sprite:Sprite):void {
            var red:uint = 0xFF0000;
            var green:uint = 0x00FF00;
            var blue:uint = 0x0000FF;
            var size:Number = 100;
            sprite.graphics.beginGradientFill(GradientType.LINEAR, [red, blue, green], [1, 0.5, 1], [0, 200, 255]);
            sprite.graphics.drawRect(0, 0, 100, 100);
        }
        public function clickHandler(event:MouseEvent):void {
            var skewMatrix:Matrix = new Matrix();
            skewMatrix.c = 0.25;
            var tempMatrix:Matrix = this.transform.matrix;
            tempMatrix.concat(skewMatrix);
            this.transform.matrix = tempMatrix;
            
            var rOffset:Number = this.transform.colorTransform.redOffset + 25;
            var bOffset:Number = this.transform.colorTransform.blueOffset - 25;
            this.transform.colorTransform = new ColorTransform(1, 1, 1, 1, rOffset, 0, bOffset, 0);            
        }
    }
}