Transform (flash.geom.Transform)


Object   |   +-flash.geom.Transform public class Transform extends Object

The Transform class collects data about color transformations and coordinate manipulations that are applied to a MovieClip object.

A Transform object is normally obtained by getting the value of the TRansform property from a MovieClip object.

Availability: ActionScript 1.0; Flash Player 8

See also

transform (MovieClip.transform property), ColorTransform (flash.geom.ColorTransform), Matrix (flash.geom.Matrix)

Property summary

Modifiers

Property

Description

 

colorTransform:ColorTransform

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

 

concatenatedColorTransform:ColorTransform [read-only]

A ColorTransform object representing the combined color transformations applied to this object and all of its parent objects, back to the root level.

 

concatenatedMatrix:Matrix [read-only]

A Matrix object representing the combined transformation matrixes of this object and all of its parent objects, back to the root level.

 

matrix:Matrix

A transformation Matrix object containing values that affect the scaling, rotation, and translation of the movie clip.

 

pixelBounds:Rectangle

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


Properties inherited from class Object

constructor (Object.constructor property), __proto__ (Object.__proto__ property), prototype (Object.prototype property), __resolve (Object.__resolve property)


Constructor summary

Signature

Description

transform (mc:MovieClip)

Creates a new Transform object attached to the given MovieClip object.


Method summary

Methods inherited from class Object

addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable (Object.isPropertyEnumerable method), isPrototypeOf (Object.isPrototypeOf method), registerClass (Object.registerClass method), toString (Object.toString method), unwatch (Object.unwatch method), valueOf (Object.valueOf method), watch (Object.watch method)


colorTransform (Transform.colorTransform property)

public colorTransform : ColorTransform

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

Availability: ActionScript 1.0; Flash Player 8

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; }

See also

ColorTransform (flash.geom.ColorTransform)

concatenatedColorTransform (Transform.concatenatedColorTransform property)

public concatenatedColorTransform : ColorTransform [read-only]

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.

Availability: ActionScript 1.0; Flash Player 8

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; }

See also

ColorTransform (flash.geom.ColorTransform)

concatenatedMatrix (Transform.concatenatedMatrix property)

public concatenatedMatrix : Matrix [read-only]

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.

Availability: ActionScript 1.0; Flash Player 8

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; }

matrix (Transform.matrix property)

public matrix : Matrix

A transformation Matrix object containing values that affect the scaling, rotation, and translation of the movie clip.

Availability: ActionScript 1.0; Flash Player 8

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; }

See also

Matrix (flash.geom.Matrix)

pixelBounds (Transform.pixelBounds property)

public pixelBounds : Rectangle

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

Availability: ActionScript 1.0; Flash Player 8

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; }

Transform constructor

public Transform(mc:MovieClip)

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.

Availability: ActionScript 1.0; Flash Player 8

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; }



ActionScript 2.0 Language Reference for Macromedia Flash 8
ActionScript 2.0 Language Reference for Macromedia Flash 8
ISBN: 0321384040
EAN: 2147483647
Year: 2004
Pages: 113

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net