View comments | RSS feed
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.

A Transform object is normally obtained by getting the value of the transform property from a display object. You can also use the new Transform() constructor to create a new Transform 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

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 CustomButton() constructor creates a new sprite object target.
  2. The CustomButton() constructor calls the draw() method, which draws a gradient square in the sprite.
  3. The CustomButton() 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.
package {
    import flash.display.Sprite;
    import flash.display.GradientType;
    import flash.geom.Matrix;
    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;
        }
    }
}




Comments


No screen name said on Jul 18, 2006 at 8:44 AM :
In the Example, do you mean the TransformExample() constructor, not the CustomButton() constructor?
swartz1999 said on Jul 19, 2006 at 11:44 AM :
Yes, the class example should refer to the TransformExample() constructor (not the CustomButton() constructor).
_depth_ said on Feb 26, 2007 at 2:11 PM :
the Transform constructor is not documented.
djtechwriter said on Feb 27, 2007 at 10:16 AM :
The docs incorrectly mention using the Transform constructor. It does exist but is not the proper way to instantiate a Transform object. It is better for users to attach a transformation object to the transform property of a display object than to use this constructor. 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.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flex/2/langref/flash/geom/Transform.html