Class: ColorTransform

graphics.geom. ColorTransform


new ColorTransform( [redMultiplier] [, greenMultiplier] [, blueMultiplier] [, alphaMultiplier] [, redOffset] [, greenOffset] [, blueOffset] [, alphaOffset])

The ColorTransform class lets you adjust the color values in a display object.

The ColorTransform class lets you adjust the color values in a display object.

The color adjustment or color transformation can be applied to all four channels: red, green, blue, and alpha transparency.

When a ColorTransform object is applied to a display object, a new value for each color channel is calculated like this:

  • New red value = (old red value redMultiplier) + redOffset
  • New green value = (old green value greenMultiplier) + greenOffset
  • New blue value = (old blue value blueMultiplier) + blueOffset
  • New alpha value = (old alpha value alphaMultiplier) + alphaOffset

If 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 can use ColorTransform objects in the following ways:

  • In the colorTransform parameter of the colorTransform() method of the BitmapData class
  • As the colorTransform property of a Transform object (which can be used as the transform property of a display object)

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.

Parameters:
Name Type Argument Default Description
redMultiplier number <optional>
1

The value for the red multiplier, in the range from 0 to 1.

greenMultiplier number <optional>
1

The value for the green multiplier, in the range from 0 to 1.

blueMultiplier number <optional>
1

The value for the blue multiplier, in the range from 0 to 1.

alphaMultiplier number <optional>
1

The value for the alpha transparency multiplier, in the range from 0 to 1.

redOffset number <optional>
0

The offset value for the red color channel, in the range from -255 to 255.

greenOffset number <optional>
0

The offset value for the green color channel, in the range from -255 to 255.

blueOffset number <optional>
0

The offset for the blue color channel value, in the range from -255 to 255.

alphaOffset number <optional>
0

The offset for alpha transparency channel value, in the range from -255 to 255.

Members


alphaMultiplier :Number

A decimal value that is multiplied with the alpha transparency channel value.

If you set the alpha transparency value of a display object directly by using the alpha property of the DisplayObject instance, it affects the value of the alphaMultiplier property of that display object's transform.colorTransform property.

Type:
  • Number
Default Value:
  • 1

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.

Type:
  • Number
Default Value:
  • 0

blueMultiplier :Number

A decimal value that is multiplied with the blue channel value.

Type:
  • Number
Default Value:
  • 1

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.

Type:
  • Number
Default Value:
  • 0

color :number

The RGB color value for a ColorTransform object.

Type:
  • number

greenMultiplier :Number

A decimal value that is multiplied with the green channel value.

Type:
  • Number
Default Value:
  • 1

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.

Type:
  • Number
Default Value:
  • 0

redMultiplier :Number

A decimal value that is multiplied with the red channel value.

Type:
  • Number
Default Value:
  • 1

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.

Type:
  • Number
Default Value:
  • 0

tint :number

The RGBA tint value for a ColorTransform object.

Type:
  • number

Methods


clone()

Create a shallow copy of the object.

Returns:

a shallow copy of the object.


concat(color)

Concatenates the ColorTransform object specified by the second parameter with the current ColorTransform object and sets the current object as the result, which is an additive combination of the two color transformations. When you apply the concatenated ColorTransform object, the effect is the same as applying the second color transformation after the original color transformation.

Parameters:
Name Type Description
color graphics.geom.ColorTransform

The ColorTransform object to be combined with the current ColorTransform object.


copyFrom(color, matrix)

Copies all of the matrix data from the source Point object into the calling Matrix object.

Parameters:
Name Type Description
color graphics.geom.ColorTransform

The ColorTransform to copy in the current object.

matrix graphics.geom.ColorTransform

The Matrix object from which to copy the data.


setTo( [redMultiplier] [, greenMultiplier] [, blueMultiplier] [, alphaMultiplier] [, redOffset] [, greenOffset] [, blueOffset] [, alphaOffset])

Sets the members of the ColorTransform to the specified values.

Parameters:
Name Type Argument Default Description
redMultiplier number <optional>
1

The value for the red multiplier, in the range from 0 to 1.

greenMultiplier number <optional>
1

The value for the green multiplier, in the range from 0 to 1.

blueMultiplier number <optional>
1

The value for the blue multiplier, in the range from 0 to 1.

alphaMultiplier number <optional>
1

The value for the alpha transparency multiplier, in the range from 0 to 1.

redOffset number <optional>
0

The offset value for the red color channel, in the range from -255 to 255.

greenOffset number <optional>
0

The offset value for the green color channel, in the range from -255 to 255.

blueOffset number <optional>
0

The offset for the blue color channel value, in the range from -255 to 255.

alphaOffset number <optional>
0

The offset for alpha transparency channel value, in the range from -255 to 255.


toObject()

Returns the Object representation of this object.

Returns:

the Object representation of this object.


toString()

Returns a text value listing the properties of the ColorTransform object.

Returns:

The text value listing the properties of the ColorTransform object.