| Properties | Methods |
Object
| Player version: | Flash Player 8 |
When a ColorTransform object is applied to a movie clip, a new value for each color channel is calculated like this:
redMultiplier) + redOffsetgreenMultiplier) + greenOffsetblueMultiplier) + blueOffsetalphaMultiplier) + alphaOffsetIf any of the color channel values is greater than 255 after the calculation, it is set to 255. If it is less than 0, it is set to 0.
You must use the new ColorTransform() constructor to create a ColorTransform object before you can call the methods of the ColorTransform object.
Color transformations do not apply to the background color of a movie clip (such as a loaded SWF object). They apply only to graphics and symbols that are attached to the movie clip.
See also| Transform.colorTransform |
| Property Summary | |
| alphaMultiplier : Number
A decimal value that is multiplied by the alpha transparency channel value. |
| alphaOffset : Number
A number from -255 to 255 that is added to the alpha transparency channel value after it has been multiplied by the alphaMultiplier value. |
| blueMultiplier : Number
A decimal value that is multiplied by the blue channel value. |
| blueOffset : Number
A number from -255 to 255 that is added to the blue channel value after it has been multiplied by the blueMultiplier value. |
| greenMultiplier : Number
A decimal value that is multiplied by the green channel value. |
| greenOffset : Number
A number from -255 to 255 that is added to the green channel value after it has been multiplied by the greenMultiplier value. |
| redMultiplier : Number
A decimal value that is multiplied by the red channel value. |
| redOffset : Number
A number from -255 to 255 that is added to the red channel value after it has been multiplied by the redMultiplier value. |
| rgb : Number
The RGB color value for a ColorTransform object. |
| Properties inherited from class Object |
__proto__, __resolve, constructor, prototype |
| Constructor Summary | |
ColorTransform([redMultiplier:Number], [greenMultiplier:Number], [blueMultiplier:Number], [alphaMultiplier:Number], [redOffset:Number], [greenOffset:Number], [blueOffset:Number], [alphaOffset:Number])
Creates a ColorTransform object for a display object with the specified color channel values and alpha values. |
|
| Method Summary | |
| concat(second:ColorTransform) : Void
Applies a second, additive color transformation to the movie clip. |
| toString() : String
Formats and returns a string that describes all of the properties of the ColorTransform object. |
| Methods inherited from class Object |
addProperty, hasOwnProperty, isPropertyEnumerable, isPrototypeOf, registerClass, toString, unwatch, valueOf, watch |
| Property Detail |
public alphaMultiplier : Number
| Player version: | Flash Player 8 |
If you set the alpha transparency value of a movie clip directly by using the MovieClip._alpha property, it affects the value of the alphaMultiplier property of that movie clip's ColorTransform object.
colorTrans and adjusts its alphaMultiplier value from 1 to .5.
import flash.geom.ColorTransform;
import flash.geom.Transform;
var colorTrans:ColorTransform = new ColorTransform();
trace(colorTrans.alphaMultiplier); // 1
colorTrans.alphaMultiplier = .5;
trace(colorTrans.alphaMultiplier); // .5
var rect:MovieClip = createRectangle(20, 80, 0x000000);
var trans:Transform = new Transform(rect);
trans.colorTransform = colorTrans;
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;
}
| MovieClip._alpha |
public alphaOffset : Number
| Player version: | Flash Player 8 |
alphaMultiplier value.
Example
colorTrans and adjusts its alphaOffset value from 0 to -128.
import flash.geom.ColorTransform;
import flash.geom.Transform;
var colorTrans:ColorTransform = new ColorTransform();
trace(colorTrans.alphaOffset); // 0
colorTrans.alphaOffset = -128;
trace(colorTrans.alphaOffset); // -128
var rect:MovieClip = createRectangle(20, 80, 0x000000);
var trans:Transform = new Transform(rect);
trans.colorTransform = colorTrans;
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 blueMultiplier : Number
| Player version: | Flash Player 8 |
colorTrans and adjusts its blueMultiplier value from 1 to .5.
import flash.geom.ColorTransform;
import flash.geom.Transform;
var colorTrans:ColorTransform = new ColorTransform();
trace(colorTrans.blueMultiplier); // 1
colorTrans.blueMultiplier = .5;
trace(colorTrans.blueMultiplier); // .5
var rect:MovieClip = createRectangle(20, 80, 0x0000FF);
var trans:Transform = new Transform(rect);
trans.colorTransform = colorTrans;
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 blueOffset : Number
| Player version: | Flash Player 8 |
blueMultiplier value.
Example
colorTrans and adjusts its blueOffset value from 0 to 255.
import flash.geom.ColorTransform;
import flash.geom.Transform;
var colorTrans:ColorTransform = new ColorTransform();
trace(colorTrans.blueOffset); // 0
colorTrans.blueOffset = 255;
trace(colorTrans.blueOffset); // 255
var rect:MovieClip = createRectangle(20, 80, 0x000000);
var trans:Transform = new Transform(rect);
trans.colorTransform = colorTrans;
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 greenMultiplier : Number
| Player version: | Flash Player 8 |
colorTrans and adjusts its greenMultiplier from 1 to .5.
import flash.geom.ColorTransform;
import flash.geom.Transform;
var colorTrans:ColorTransform = new ColorTransform();
trace(colorTrans.greenMultiplier); // 1
colorTrans.greenMultiplier = .5;
trace(colorTrans.greenMultiplier); // .5
var rect:MovieClip = createRectangle(20, 80, 0x00FF00);
var trans:Transform = new Transform(rect);
trans.colorTransform = colorTrans;
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 greenOffset : Number
| Player version: | Flash Player 8 |
greenMultiplier value.
Example
colorTrans and adjusts its greenOffset value from 0 to 255.
import flash.geom.ColorTransform;
import flash.geom.Transform;
var colorTrans:ColorTransform = new ColorTransform();
trace(colorTrans.greenOffset); // 0
colorTrans.greenOffset = 255;
trace(colorTrans.greenOffset); // 255
var rect:MovieClip = createRectangle(20, 80, 0x000000);
var trans:Transform = new Transform(rect);
trans.colorTransform = colorTrans;
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 redMultiplier : Number
| Player version: | Flash Player 8 |
colorTrans and adjusts its redMultiplier value from 1 to .5.
import flash.geom.ColorTransform;
import flash.geom.Transform;
var colorTrans:ColorTransform = new ColorTransform();
trace(colorTrans.redMultiplier); // 1
colorTrans.redMultiplier = .5;
trace(colorTrans.redMultiplier); // .5
var rect:MovieClip = createRectangle(20, 80, 0xFF0000);
var trans:Transform = new Transform(rect);
trans.colorTransform = colorTrans;
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 redOffset : Number
| Player version: | Flash Player 8 |
redMultiplier value.
Example
colorTrans and adjusts its redOffset value from 0 to 255.
import flash.geom.ColorTransform;
import flash.geom.Transform;
var colorTrans:ColorTransform = new ColorTransform();
trace(colorTrans.redOffset); // 0
colorTrans.redOffset = 255;
trace(colorTrans.redOffset); // 255
var rect:MovieClip = createRectangle(20, 80, 0x000000);
var trans:Transform = new Transform(rect);
trans.colorTransform = colorTrans;
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 rgb : Number
| Player version: | Flash Player 8 |
When you set this property, it changes the three color offset values (redOffset, greenOffset, and blueOffset) accordingly, and it sets the three color multiplier values (redMultiplier, greenMultiplier, and blueMultiplier) to 0. The alpha transparency multiplier and offset values do not change.
Pass a value for this property in the format: 0xRRGGBB. RR, GG, and BB each consist of two hexadecimal digits that specify the offset of each color component. The 0x tells the ActionScript compiler that the number is a hexadecimal value.
ExamplecolorTrans and adjusts its rgb value to 0xFF0000.
import flash.geom.ColorTransform;
import flash.geom.Transform;
var colorTrans:ColorTransform = new ColorTransform();
trace(colorTrans.rgb); // 0
colorTrans.rgb = 0xFF0000;
trace(colorTrans.rgb); // 16711680
trace("0x" + colorTrans.rgb.toString(16)); // 0xff0000
var rect:MovieClip = createRectangle(20, 80, 0x000000);
var trans:Transform = new Transform(rect);
trans.colorTransform = colorTrans;
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;
}
| Constructor Detail |
public ColorTransform([redMultiplier:Number], [greenMultiplier:Number], [blueMultiplier:Number], [alphaMultiplier:Number], [redOffset:Number], [greenOffset:Number], [blueOffset:Number], [alphaOffset:Number])
| Player version: | Flash Player 8 |
redMultiplier:Number [optional] — The value for the red multiplier, in the range from 0 to 1. The default value is 1. |
|
greenMultiplier:Number [optional] — The value for the green multiplier, in the range from 0 to 1. The default value is 1. |
|
blueMultiplier:Number [optional] — The value for the blue multiplier, in the range from 0 to 1. The default value is 1. |
|
alphaMultiplier:Number [optional] — The value for the alpha transparency multiplier, in the range from 0 to 1. The default value is 1. |
|
redOffset:Number [optional] — The offset for the red color channel value (-255 to 255). The default value is 0. |
|
greenOffset:Number [optional] — The offset for the green color channel value (-255 to 255). The default value is 0. |
|
blueOffset:Number [optional] — The offset for the blue color channel value (-255 to 255). The default value is 0. |
|
alphaOffset:Number [optional] — The offset for alpha transparency channel value (-255 to 255). The default value is 0. |
greenTransform: var greenTransform:flash.geom.ColorTransform = new flash.geom.ColorTransform(0.5, 1.0, 0.5, 0.5, 10, 10, 10, 0);
colorTrans_1 with the default constructor values. The fact that colorTrans_1 and colorTrans_2 trace the same values is evidence that the default constructor values are used. import flash.geom.ColorTransform; var colorTrans_1:ColorTransform = new ColorTransform(1, 1, 1, 1, 0, 0, 0, 0); trace(colorTrans_1); //(redMultiplier=1, greenMultiplier=1, blueMultiplier=1, alphaMultiplier=1, redOffset=0, greenOffset=0, blueOffset=0, alphaOffset=0) var colorTrans_2:ColorTransform = new ColorTransform(); trace(colorTrans_2); //(redMultiplier=1, greenMultiplier=1, blueMultiplier=1, alphaMultiplier=1, redOffset=0, greenOffset=0, blueOffset=0, alphaOffset=0)
| Method Detail |
public concat(second:ColorTransform) : Void
| Player version: | Flash Player 8 |
second:ColorTransform — A second ColorTransform object to be combined with the current ColorTransform object. |
colorTrans_2 to colorTrans_1 resulting in a full red offset combined with a .5 alpha multiplier.
import flash.geom.ColorTransform;
import flash.geom.Transform;
var colorTrans_1:ColorTransform = new ColorTransform(1, 1, 1, 1, 255, 0, 0, 0);
trace(colorTrans_1);
// (redMultiplier=1, greenMultiplier=1, blueMultiplier=1, alphaMultiplier=1, redOffset=255, greenOffset=0, blueOffset=0, alphaOffset=0)
var colorTrans_2:ColorTransform = new ColorTransform(1, 1, 1, .5, 0, 0, 0, 0);
trace(colorTrans_2);
// (redMultiplier=1, greenMultiplier=1, blueMultiplier=1, alphaMultiplier=0.5, redOffset=0, greenOffset=0, blueOffset=0, alphaOffset=0)
colorTrans_1.concat(colorTrans_2);
trace(colorTrans_1);
// (redMultiplier=1, greenMultiplier=1, blueMultiplier=1, alphaMultiplier=0.5, redOffset=255, greenOffset=0, blueOffset=0, alphaOffset=0)
var rect:MovieClip = createRectangle(20, 80, 0x000000);
var trans:Transform = new Transform(rect);
trans.colorTransform = colorTrans_1;
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 toString() : String
| Player version: | Flash Player 8 |
String —
A string that lists all of the properties of the ColorTransform object.
|
colorTrans and calls its toSting() method. This method results in a string with the following format: (redMultiplier=RM, greenMultiplier=GM, blueMultiplier=BM, alphaMultiplier=AM, redOffset=RO, greenOffset=GO, blueOffset=BO, alphaOffset=AO). import flash.geom.ColorTransform; var colorTrans:ColorTransform = new ColorTransform(1, 2, 3, 4, -255, -128, 128, 255); trace(colorTrans.toString()); // (redMultiplier=1, greenMultiplier=2, blueMultiplier=3, alphaMultiplier=4, redOffset=-255, greenOffset=-128, blueOffset=128, alphaOffset=255)
| Properties | Methods |