The ColorTransform Class
The ColorTransform class is an object containing specific RGB and alpha properties.It is important when using this class to import it first at the beginning of your script, like this:
To instantiate a new instance of the GradientGlowFilter class, use this code as a template:
import flash.geom.ColorTransform;
[View full width]var myTransform:ColorTransform = new ColorTransform(redMult, greenMult, blueMult,alphaMult, redOff, greenOff, blueOff, alphaOff);
- redMult
Numerical value of red multiplier from 01. - greenMult
Numerical value of green multiplier from 01. - blueMult
Numerical value of blue multiplier from 01. - alphaMult
Numerical value of alpha multiplier from 01. - redOff
The offset of the red channel from 255 to 255. - greenOff
The offset of the green channel from 255 to 255. - blueOff
The offset of the blue channel from 255 to 255. - alphaOff
The offset of the alpha channel from 255 to 255.
Example :This example will create an instance of the ColorTransform class:
Because all but one of the properties of this object match the parameters identically, they will be skipped.
import flash.geom.ColorTransform;
var myTransform:ColorTransform = new flash.geom.ColorTransform (1, .7, .8, 1, 5, 15, 25, 0);
Properties
rgb
Availability :
FP:8, AS:1.0 Generic Template :
mytransform.rgbDescription: This property contains the RGB value of a ColorTransform object.Example: This example will create a ColorTransform object and send the rgb property to the Output panel:
import flash.geom.ColorTransform;
var myTransform:ColorTransform = new flash.geom.ColorTransform (1, .7, .8, 1, 5, 15, 25, 0);
trace(myTransform.rgb);
//output: 331545
Methods
concat
Availability :
FP:8, AS:1.0Generic Template :
myTRansform.concat(colorTransform);Parameters:
- colorTransform
A second ColorTransform object.
Description: This method will add a second color transformation to a movie clip.Example: This example will import the necessary class file. Then we create the first instance of the ColorTransform object we need and trace its redOffset property. Next, the second ColorTransform object is created and concatenated to the first. Finally, the redOffset property of the first object is traced again to reveal it has changed:
import flash.geom.ColorTransform;
//first ColorTransform object
var myTrans:ColorTransform = new ColorTransform(1, 1, 1, 1, 200, 0, 0, 0);
trace(myTrans.redOffset);
//second ColorTransform object
var myTrans2:ColorTransform = new ColorTransform(1, 1, 1, .5, 55, 0, 0, 0);
//concat the color transforms
myTrans.concat(myTrans2);
trace(myTrans.redOffset);
//output: 200
// 255
toString
Availability :
FP:8, AS:1.0 Generic Template :
mytransform.toString();Returns :
StringThis method will return a formatted string containing all the ColorTransform properties.Description: This method will return a formatted string with each individual property labeled and defined.Example: This example will create a ColorTransform object and trace all of its properties using the toString method:
[View full width]var myTransform:ColorTransform = new flash.geom.ColorTransform (1, .7, .8, 1, 5, 15, 25, 0);
trace(myTransform.toString());
//output: (redMultiplier=1, greenMultiplier=0.7, blueMultiplier=0.8, alphaMultiplier=1,redOffset=5, greenOffset=15, blueOffset=25, alphaOffset=0)