public var colorTransform:ColorTransform
Player version: | Flash Player 8 |
A ColorTransform object containing values that universally adjust the colors in the movie clip.
See also
Example
The following example applies the ColorTransform object
blueColorTransform
to the Transform object
trans
. This ColorTransform converts the color of the MovieClip
rect
from red to blue.
import flash.geom.Transform;
import flash.geom.ColorTransform;
var rect:MovieClip = createRectangle(20, 80, 0xFF0000);
var trans:Transform = new Transform(rect);
trace(trans.colorTransform);
// (redMultiplier=1, greenMultiplier=1, blueMultiplier=1, alphaMultiplier=1, redOffset=0, greenOffset=0, blueOffset=0, alphaOffset=0)
var blueColorTransform:ColorTransform = new ColorTransform(0, 1, 1, 1, 0, 0, 255, 0);
rect.onPress = function() {
trans.colorTransform = blueColorTransform;
trace(trans.colorTransform);
// (redMultiplier=0, greenMultiplier=1, blueMultiplier=1, alphaMultiplier=1, redOffset=0, greenOffset=0, blueOffset=255, alphaOffset=0)
}
function createRectangle(width:Number, height:Number, color:Number, scope:MovieClip):MovieClip {
scope = (scope == undefined) ? this : scope;
var depth:Number = scope.getNextHighestDepth();
var mc:MovieClip = scope.createEmptyMovieClip("mc_" + depth, depth);
mc.beginFill(color);
mc.lineTo(0, height);
mc.lineTo(width, height);
mc.lineTo(width, 0);
mc.lineTo(0, 0);
return mc;
}
concatenatedColorTransform:ColorTransform
[read-only]
Player version: | Flash Player 8 |
A ColorTransform object representing the combined color transformations applied to this object and all of its parent objects, back to the root level. If different color transformations have been applied at different levels, each of those transformations will be concatenated into one ColorTransform object for this property.
Implementation
public function get concatenatedColorTransform():ColorTransform
See also
Example
The following example applies two Transform objects to both a parent and child MovieClip object. A
blueColorTransform
variable is then applied to the Transform object
parentTrans
, which adjusts the color of both parent and child MovieClip objects toward blue. You can see how
child.concatenatedColorTransform
is the combination of
parentTrans
and
childTrans
.
import flash.geom.Transform;
import flash.geom.ColorTransform;
var parentRect:MovieClip = createRectangle(20, 80, 0xFF0000);
var childRect:MovieClip = createRectangle(10, 40, 0x00FF00, parentRect);
var parentTrans:Transform = new Transform(parentRect);
var childTrans:Transform = new Transform(childRect);
var blueColorTransform:ColorTransform = new ColorTransform(0, 1, 1, 1, 0, 0, 255, 0);
parentTrans.colorTransform = blueColorTransform;
trace(childTrans.concatenatedColorTransform);
// (redMultiplier=0, greenMultiplier=1, blueMultiplier=1, alphaMultiplier=1, redOffset=0, greenOffset=0, blueOffset=255, alphaOffset=0)
trace(childTrans.colorTransform);
// (redMultiplier=1, greenMultiplier=1, blueMultiplier=1, alphaMultiplier=1, redOffset=0, greenOffset=0, blueOffset=0, alphaOffset=0)
trace(parentTrans.concatenatedColorTransform);
// (redMultiplier=0, greenMultiplier=1, blueMultiplier=1, alphaMultiplier=1, redOffset=0, greenOffset=0, blueOffset=255, alphaOffset=0)
function createRectangle(width:Number, height:Number, color:Number, scope:MovieClip):MovieClip {
scope = (scope == undefined) ? this : scope;
var depth:Number = scope.getNextHighestDepth();
var mc:MovieClip = scope.createEmptyMovieClip("mc_" + depth, depth);
mc.beginFill(color);
mc.lineTo(0, height);
mc.lineTo(width, height);
mc.lineTo(width, 0);
mc.lineTo(0, 0);
return mc;
}
concatenatedMatrix:Matrix
[read-only]
Player version: | Flash Player 8 |
A Matrix object representing the combined transformation matrixes of this object and all of its parent objects, back to the root level. If different transformation matrixes have been applied at different levels, each of those matrixes will be concatenated into one matrix for this property.
Implementation
public function get concatenatedMatrix():Matrix
Example
The following example applies two Transform objects to both a child and parent MovieClip object. A
scaleMatrix
is then applied to the Transform object
parentTrans
, which scales both parent and child MovieClip objects. You can see how
child.concatenatedMatrix
is the combination of
parentTrans
and
childTrans
.
import flash.geom.Transform;
import flash.geom.Matrix;
var parentRect:MovieClip = createRectangle(20, 80, 0xFF0000);
var childRect:MovieClip = createRectangle(10, 40, 0x00FF00, parentRect);
var parentTrans:Transform = new Transform(parentRect);
var childTrans:Transform = new Transform(childRect);
var scaleMatrix:Matrix = new Matrix();
scaleMatrix.scale(2, 2);
parentTrans.matrix = scaleMatrix;
trace(childTrans.concatenatedMatrix); // (a=2, b=0, c=0, d=2, tx=0, ty=0)
trace(childTrans.matrix); // (a=1, b=0, c=0, d=1, tx=0, ty=0)
trace(parentTrans.concatenatedMatrix); // (a=2, b=0, c=0, d=2, tx=0, ty=0)
function createRectangle(width:Number, height:Number, color:Number, scope:MovieClip):MovieClip {
scope = (scope == undefined) ? this : scope;
var depth:Number = scope.getNextHighestDepth();
var mc:MovieClip = scope.createEmptyMovieClip("mc_" + depth, depth);
mc.beginFill(color);
mc.lineTo(0, height);
mc.lineTo(width, height);
mc.lineTo(width, 0);
mc.lineTo(0, 0);
return mc;
}
public var matrix:Matrix
Player version: | Flash Player 8 |
A transformation Matrix object containing values that affect the scaling, rotation, and translation of the movie clip.
See also
Example
The following example applies the Matrix object
scaleMatrix
to the Transform object
trans
. This Matrix scales the MovieClip
rect
by a factor of two.
import flash.geom.Transform;
import flash.geom.Matrix;
var rect:MovieClip = createRectangle(20, 80, 0xFF0000);
var trans:Transform = new Transform(rect);
trace(trans.matrix); // (a=1, b=0, c=0, d=1, tx=0, ty=0)
var scaleMatrix:Matrix = new Matrix();
scaleMatrix.scale(2, 2);
rect.onPress = function() {
trans.matrix = scaleMatrix;
trace(trans.matrix); // (a=2, b=0, c=0, d=2, tx=0, ty=0)
}
function createRectangle(width:Number, height:Number, color:Number, scope:MovieClip):MovieClip {
scope = (scope == undefined) ? this : scope;
var depth:Number = scope.getNextHighestDepth();
var mc:MovieClip = scope.createEmptyMovieClip("mc_" + depth, depth);
mc.beginFill(color);
mc.lineTo(0, height);
mc.lineTo(width, height);
mc.lineTo(width, 0);
mc.lineTo(0, 0);
return mc;
}
public var pixelBounds:Rectangle
Player version: | Flash Player 8 |
A Rectangle object that defines the bounding rectangle of the MovieClip object on the Stage.
Example
The following example creates a Transform object
trans
and traces out its
pixelBounds
property. Notice that
pixelBounds
returns a bounding box with values equal to the MovieClip object's
getBounds()
and
getRect()
methods.
import flash.geom.Transform;
var rect:MovieClip = createRectangle(20, 80, 0xFF0000);
var trans:Transform = new Transform(rect);
trace(trans.pixelBounds); // (x=0, y=0, w=20, h=80)
var boundsObj:Object = rect.getBounds();
trace(boundsObj.xMin); // 0
trace(boundsObj.yMin); // 0
trace(boundsObj.xMax); // 20
trace(boundsObj.yMax); // 80
var rectObj:Object = rect.getRect();
trace(rectObj.xMin); // 0
trace(rectObj.yMin); // 0
trace(rectObj.xMax); // 20
trace(rectObj.yMax); // 80
function createRectangle(width:Number, height:Number, color:Number, scope:MovieClip):MovieClip {
scope = (scope == undefined) ? this : scope;
var depth:Number = scope.getNextHighestDepth();
var mc:MovieClip = scope.createEmptyMovieClip("mc_" + depth, depth);
mc.beginFill(color);
mc.lineTo(0, height);
mc.lineTo(width, height);
mc.lineTo(width, 0);
mc.lineTo(0, 0);
return mc;
}
public function Transform(mc:MovieClip)
Player version: | Flash Player 8 |
Creates a new Transform object attached to the given MovieClip object.
When it is created the new Transform object can be retrieved by getting the transform
property of the given MovieClip object.
Parameters
| mc:MovieClip — The MovieClip object to which the new Transform object is applied. |
Example
The following example creates the Transform
trans
and applies it to the MovieClip
rect. You can see that the Transform object's
trans
and
rect.transform
do not evaluate as equals even though they contain the same values.
import flash.geom.Transform;
var rect:MovieClip = createRectangle(20, 80, 0xFF0000);
var trans:Transform = new Transform(rect);
trace(rect.transform == trans); // false
for(var i in trans) {
trace(">> " + i + ": " + trans[i]);
// >> pixelBounds: (x=0, y=0, w=20, h=80)
// >> concatenatedColorTransform: (redMultiplier=1, greenMultiplier=1, blueMultiplier=1, alphaMultiplier=1, redOffset=0, greenOffset=0, blueOffset=0, alphaOffset=0)
// >> colorTransform: (redMultiplier=1, greenMultiplier=1, blueMultiplier=1, alphaMultiplier=1, redOffset=0, greenOffset=0, blueOffset=0, alphaOffset=0)
// >> concatenatedMatrix: (a=1, b=0, c=0, d=1, tx=0, ty=0)
// >> matrix: (a=1, b=0, c=0, d=1, tx=0, ty=0)
}
for(var i in rect.transform) {
trace(">> " + i + ": " + rect.transform[i]);
// >> pixelBounds: (x=0, y=0, w=20, h=80)
// >> concatenatedColorTransform: (redMultiplier=1, greenMultiplier=1, blueMultiplier=1, alphaMultiplier=1, redOffset=0, greenOffset=0, blueOffset=0, alphaOffset=0)
// >> colorTransform: (redMultiplier=1, greenMultiplier=1, blueMultiplier=1, alphaMultiplier=1, redOffset=0, greenOffset=0, blueOffset=0, alphaOffset=0)
// >> concatenatedMatrix: (a=1, b=0, c=0, d=1, tx=0, ty=0)
// >> matrix: (a=1, b=0, c=0, d=1, tx=0, ty=0)
}
function createRectangle(width:Number, height:Number, color:Number, scope:MovieClip):MovieClip {
scope = (scope == undefined) ? this : scope;
var depth:Number = scope.getNextHighestDepth();
var mc:MovieClip = scope.createEmptyMovieClip("mc_" + depth, depth);
mc.beginFill(color);
mc.lineTo(0, height);
mc.lineTo(width, height);
mc.lineTo(width, 0);
mc.lineTo(0, 0);
return mc;
}