XColor (com.robertpenner.graphics.XColor)

Color
        |
        +--com.robertpenner.graphics.XColor
class XColor
extends Color

The XColor class extends the Color class adding a collection of utilities that allows for more intuitive color manipulation.

Availability:

ActionScript 2.0; Flash Player 6

Property summary

Property Description
rgb:Number

The rgb property of the XColor object.

rgbStr:String

The rgbStr property of the XColor object.

brightness:Number

The brightness property of the XColor object.

brightOffset:Number

The brightOffset property of the XColor object.

negative:Number

The negative property of the XColor object.

red:Number

The red property of the XColor object.

green:Number

The green property of the XColor object.

blue:Number

The blue property of the XColor object.

redPercent:Number

The redPercent property of the XColor object.

greenPercent:Number

The greenPercent property of the XColor object.

bluePercent:Number

The bluePercent property of the XColor object.

redOffset:Number

The redOffset property of the XColor object.

greenOffset:Number

The greenOffset property of the XColor object.

blueOffset:Number

The blueOffset property of the XColor object.

Method summary

Method Description
setRGB(col:Number) : Void

Specifies an RGB color for an XColor object.

getRGB() : Number

Returns the R+G+B combination currently in use by the XColor object.

setRGBStr(hexStr:String) : Void

Specifies an RGB color for an XColor object using a string hexadecimal value.

getRGBStr() : String

Returns the R+G+B combination currently in use by the XColor object as a string hexadecimal value.

setRGB2(r:Number, g:Number, b:Number) : Void

Specifies an RGB color for an XColor object using individual red, green, and blue values.

getRGB2() : Object

Returns the R+G+B values currently in use by the XColor object as individual red, green, and blue values.

setTransform(trans:Object) : Void

Sets color transform information for an XColor object.

getTransform() : Object

Returns the transform value set by the last XColor.setTransform() call.

reset() : Void

Sets the color transform for an XColor object to its default values.

setBrightness(bright:Number) : Void

Specifies the brightness of an XColor object.

getBrightness() : Number

Returns the brightness of an XColor object.

setBrightOffset(offset:Number) : Void

Pushes an XColor object towards black or white by an absolute amount.

getBrightOffset() : Number

Returns the brightness offset value of an XColor object.

setTint(r:Number, g:Number, b:Number, percent:Number) : Void

Tints an XColor object with a color according to a certain percentage.

getTint() : Object

Returns the tint of an XColor object.

setTint2(rgb:Number, percent:Number) : Void

Tints an XColor object with a color according to a certain percentage.

getTint2() : Object

Returns the tint of an XColor object.

setTintOffset(r:Number, g:Number, b:Number) : Void

Tints an XColor object with a color according to red, green, and blue values.

getTintOffset() : Object

Returns the tint offset of an XColor object.

setTintOffset2(rgb:Number) : Void

Tints an XColor object with a color according to an rgb value.

getTintOffset2() : Number

Returns the tint offset of an XColor object.

invert() : Void

Performs a straightforward color inversion.

setNegative(percent:Number) : Void

Inverts an XColor object by a certain percentage.

getNegative() : Number

Returns the negative percentage of an XColor object.

setRed(amount:Number) : Void

Specifies a red color value for an XColor object.

getRed() : Number

Returns the red color value of an XColor object.

setGreen(amount:Number) : Void

Specifies a green color value for an XColor object.

getGreen() : Number

Returns the green color value of an XColor object.

setBlue(amount:Number) : Void

Specifies a blue color value for an XColor object.

getBlue() : Number

Returns the blue color value of an XColor object.

setRedPercent(percent:Number) : Void

Specifies a red percentage value for an XColor object.

getRedPercent() : Number

Returns the red percentage value of an XColor object.

setGreenPercent(percent:Number) : Void

Specifies a green percentage value for an XColor object.

getGreenPercent() : Number

Returns the green percentage value of an XColor object.

setBluePercent(percent:Number) : Void

Specifies a blue percentage value for an XColor object.

getBluePercent() : Number

Returns the blue percentage value of an XColor object.

setRedOffset(offset:Number) : Void

Specifies a red offset value for an XColor object.

getRedOffset() : Number

Returns the red offset value of an XColor object.

setGreenOffset(offset:Number) : Void

Specifies a green offset value for an XColor object.

getGreenOffset() : Number

Returns the green offset value of an XColor object.

setBlueOffset(offset:Number) : Void

Specifies a blue offset value for an XColor object.

getBlueOffset() : Number

Returns the blue offset value of an XColor object.

setRGB(col:Number) : Void

Usage


var my_color:XColor = new XColor(my_mc);
my_color.setRGB(0xFFFF00);

Parameters

col:Number - The hexadecimal or RGB color to be set.

Returns

Nothing.

Description

Specifies an RGB color for an XColor object.


getRGB() : Number

Usage


var my_color:XColor = new XColor(my_mc);
trace (my_color.getRGB());

Parameters

Returns

A number that represents the RGB numeric value for the color specified.

Description

Returns the R+G+B combination currently in use by the XColor object.


setRGBStr(hexStr:String) : Void

Usage


var my_color:XColor = new XColor(my_mc);
my_color.setRGBStr("#FFFF00");

Parameters

hexStr:String - The string hexadecimal color to be set.

Returns

Nothing.

Description

Specifies an RGB color for an XColor object using a string hexadecimal value.


getRGBStr() : String

Usage


var my_color:XColor = new XColor(my_mc);
trace (my_color.getRGBStr());

Parameters

Returns

The string hexadecimal color.

Description

Returns the R+G+B combination currently in use by the XColor object as a string hexadecimal value.


setRGB2(r:Number, g:Number, b:Number) : Void

Usage


var my_color:XColor = new XColor(my_mc);
my_color.setRGB2(255, 0, 255);

Parameters

r:Number - The red color value.

g:Number - The green color value.

b:Number - The blue color value.

Returns

Nothing.

Description

Specifies an RGB color for an XColor object using individual red, green, and blue values.


getRGB2() : Object

Usage


var my_color:XColor = new XColor(my_mc);
my_color.setRGB2(255, 0, 255);
var rgb:Object = my_color.getRGB2();
trace (rgb.r);
trace (rgb.g);
trace (rgb.b);

Parameters

Returns

The RBG value object with r, g, and b properties.

Description

Returns the R+G+B values currently in use by the XColor object as individual red, green, and blue values.


setTransform(trans:Object) : Void

Usage


var my_color:XColor = new XColor(my_mc);
var my_trans:Object = {ra:50, rb:244, ga:40, gb:112, ba:12, bb:90, aa:40, ab:70};
my_color.setTransform(my_trans);

Parameters

trans:Object - An object that must have the following properties that specify color transform values: ra, rb, ga, gb, ba, bb, aa, ab.

Returns

Nothing.

Description

Sets color transform information for an XColor object.


getTransform() : Object

Usage


var my_color:XColor = new XColor(my_mc);
var trans:Object = my_color.getTransform();
trace ([trans.ra, trans.rb, trans.ga, trans.gb, trans.ba, trans.bb, trans.aa, trans.ab]);

Parameters

Returns

An object whose properties contain the current offset and percentage values for the specified color.

Description

Returns the transform value set by the last XColor.setTransform() call.


reset() : Void

Usage


var my_color:XColor = new XColor(my_mc);
my_color.setRGB(0x0000FF);
my_color.reset();

Parameters

Returns

Nothing.

Description

Sets the color transform for an XColor object to its default values.


setBrightness(bright:Number) : Void

Usage


var my_color:XColor = new XColor(my_mc);
my_color.setBrightness(50);

Parameters

bright:Number - A percentage value between -100 and 100. Positive values brighten the color. and negative values darken it.

Returns

Nothing.

Description

Specifies the brightness of an XColor object.


getBrightness() : Number

Usage


var my_color:XColor = new XColor(my_mc);
my_color.setBrightness(50);
trace (my_color.getBrightness());

Parameters

Returns

The brightness value.

Description

Returns the brightness of an XColor object.


setBrightOffset(offset:Number) : Void

Usage


var my_color:XColor = new XColor(my_mc);
my_color.setBrightOffset(140);

Parameters

offset:Number - A number between -255 and 255. Positive values push colors towards white; negative values towards black.

Returns

Nothing.

Description

Pushes an XColor object towards black or white by an absolute amount.


getBrightOffset() : Number

Usage


var my_color:XColor = new XColor(my_mc);
my_color.setBrightOffset(140);
trace (my_color.getBrightOffset());

Parameters

Returns

The brightness offset value.

Description

Returns the brightness offset value of an XColor object.


setTint(r:Number, g:Number, b:Number, percent:Number) : Void

Usage


var my_color:XColor = new XColor(my_mc);
my_color.setTint(0, 0, 128, 50);

Parameters

r:Number - The red color value.

g:Number - The green color value.

b:Number - The blue color value.

percent:Number - The tint percentage.

Returns

Nothing.

Description

Tints an XColor object with a color according to a certain percentage.


getTint() : Object

Usage


var my_color:XColor = new XColor(my_mc);
my_color.setTint(0, 0, 128, 50);
var tint:Object = my_color.getTint();
trace (tint.r);
trace (tint.g);
trace (tint.b);
trace (tint.percent);

Parameters

Returns

The tint value object with r, g, b, and percent properties.

Description

Returns the tint of an XColor object.


setTint2(rgb:Number, percent:Number) : Void

Usage


var my_color:XColor = new XColor(my_mc);
my_color.setTint2(0x0000FF, 100);

Parameters

rgb:Number - The rgb value.

percent:Number - The tint percentage.

Returns

Nothing.

Description

Tints an XColor object with a color according to a certain percentage.


getTint2() : Object

Usage


var my_color:XColor = new XColor(my_mc);
my_color.setTint2(0x0000FF, 100);
var tint:Object = my_color.getTint2();
trace (tint.rgb);
trace (tint.percent);

Parameters

Returns

The tint value object with rgb and percent properties.

Description

Returns the tint of an XColor object.


setTintOffset(r:Number, g:Number, b:Number) : Void

Usage


var my_color:XColor = new XColor(my_mc);
my_color.setTintOffset(0, 0, 128);

Parameters

r:Number - The red color value.

g:Number - The green color value.

b:Number - The blue color value.

Returns

Nothing.

Description

Tints an XColor object with a color according to red, green, and blue values.


getTintOffset() : Object

Usage


var my_color:XColor = new XColor(my_mc);
my_color.setTintOffset(0, 0, 128);
var tint:Object = my_color.getTintOffset();
trace (tint.r);
trace (tint.g);
trace (tint.b);

Parameters

Returns

The tint offset value object with r, g, and b properties.

Description

Returns the tint offset of an XColor object.


setTintOffset2(rgb:Number) : Void

Usage


var my_color:XColor = new XColor(my_mc);
my_color.setTintOffset2(0x000080);

Parameters

rgb:Number - The rgb value.

Returns

Nothing.

Description

Tints an XColor object with a color according to an rgb value.


getTintOffset2() : Number

Usage


var my_color:XColor = new XColor(my_mc);
my_color.setTintOffset2(0x000080);
trace (my_color.getTintOffset2());

Parameters

Returns

The tint offset value object with an rgb properties.

Description

Returns the tint offset of an XColor object.


invert() : Void

Usage


var my_color:XColor = new XColor(my_mc);
my_color.invert();

Parameters

Returns

Nothing.

Description

Performs a straightforward color inversion.


setNegative(percent:Number) : Void

Usage


var my_color:XColor = new XColor(my_mc);
my_color.setNegative(60);

Parameters

percent:Number - The negative percentage.

Returns

Nothing.

Description

Inverts an XColor object by a certain percentage.


getNegative() : Number

Usage


var my_color:XColor = new XColor(my_mc);
my_color.setNegative(60);
trace (my_color.getNegative());

Parameters

Returns

The negative percentage.

Description

Returns the negative percentage of an XColor object.


setRed(amount:Number) : Void

Usage


var my_color:XColor = new XColor(my_mc);
my_color.setRed(128);

Parameters

amount:Number - The red color value.

Returns

Nothing.

Description

Specifies a red color value for an XColor object.


getRed() : Number

Usage


var my_color:XColor = new XColor(my_mc);
my_color.setRed(128);
trace (my_color.getRed());

Parameters

Returns

The red color value.

Description

Returns the red color value of an XColor object.


setGreen(amount:Number) : Void

Usage


var my_color:XColor = new XColor(my_mc);
my_color.setGreen(128);

Parameters

amount:Number - The green color value.

Returns

Nothing.

Description

Specifies a green color value for an XColor object.


getGreen() : Number

Usage


var my_color:XColor = new XColor(my_mc);
my_color.setGreen(128);
trace (my_color.getGreen());

Parameters

Returns

The green color value.

Description

Returns the green color value of an XColor object.


setBlue(amount:Number) : Void

Usage


var my_color:XColor = new XColor(my_mc);
my_color.setBlue(128);

Parameters

amount:Number - The blue color value.

Returns

Nothing.

Description

Specifies a blue color value for an XColor object.


getBlue() : Number

Usage


var my_color:XColor = new XColor(my_mc);
my_color.setBlue(128);
trace (my_color.getBlue());

Parameters

Returns

The blue color value.

Description

Returns the blue color value of an XColor object.


setRedPercent(percent:Number) : Void

Usage


var my_color:XColor = new XColor(my_mc);
my_color.setRedPercent(50);

Parameters

percent:Number - The red percentage value.

Returns

Nothing.

Description

Specifies a red percentage value for an XColor object.


getRedPercent() : Number

Usage


var my_color:XColor = new XColor(my_mc);
my_color.setRedPercent(50);
trace (my_color.getRedPercent());

Parameters

Returns

The red percentage value.

Description

Returns the red percentage value of an XColor object.


setGreenPercent(percent:Number) : Void

Usage


var my_color:XColor = new XColor(my_mc);
my_color.setGreenPercent(50);

Parameters

percent:Number - The green percentage value.

Returns

Nothing.

Description

Specifies a green percentage value for an XColor object.


getGreenPercent() : Number

Usage


var my_color:XColor = new XColor(my_mc);
my_color.setGreenPercent(50);
trace (my_color.getGreenPercent());

Parameters

Returns

The green percentage value.

Description

Returns the green percentage value of an XColor object.


setBluePercent(percent:Number) : Void

Usage


var my_color:XColor = new XColor(my_mc);
my_color.setBluePercent(50);

Parameters

percent:Number - The blue percentage value.

Returns

Nothing.

Description

Specifies a blue percentage value for an XColor object.


getBluePercent() : Number

Usage


var my_color:XColor = new XColor(my_mc);
my_color.setBluePercent(50);
trace (my_color.getBluePercent());

Parameters

Returns

The blue percentage value.

Description

Returns the blue percentage value of an XColor object.


setRedOffset(offset:Number) : Void

Usage


var my_color:XColor = new XColor(my_mc);
my_color.setRedOffset(-128);

Parameters

percent: - The red offset value.

Returns

Nothing.

Description

Specifies a red offset value for an XColor object.


getRedOffset() : Number

Usage


var my_color:XColor = new XColor(my_mc);
my_color.setRedOffset(-128);
trace (my_color.getRedOffset());

Parameters

Returns

The red offset value.

Description

Returns the red offset value of an XColor object.


setGreenOffset(offset:Number) : Void

Usage


var my_color:XColor = new XColor(my_mc);
my_color.setGreenOffset(-128);

Parameters

percent: - The green offset value.

Returns

Nothing.

Description

Specifies a green offset value for an XColor object.


getGreenOffset() : Number

Usage


var my_color:XColor = new XColor(my_mc);
my_color.setGreenOffset(-128);
trace (my_color.getGreenOffset());

Parameters

Returns

The green offset value.

Description

Returns the green offset value of an XColor object.


setBlueOffset(offset:Number) : Void

Usage


var my_color:XColor = new XColor(my_mc);
my_color.setBlueOffset(-128);

Parameters

percent: - The blue offset value.

Returns

Nothing.

Description

Specifies a blue offset value for an XColor object.


getBlueOffset() : Number

Usage


var my_color:XColor = new XColor(my_mc);
my_color.setBlueOffset(-128);
trace (my_color.getBlueOffset());

Parameters

Returns

The blue offset value.

Description

Returns the blue offset value of an XColor object.


rgb : Number

Usage


trace (my_color.rgb);

Description

The rgb property of the XColor object.


rgbStr : String

Usage


trace (my_color.rgbStr);

Description

The rgbStr property of the XColor object.


brightness : Number

Usage


trace (my_color.brightness);

Description

The brightness property of the XColor object.


brightOffset : Number

Usage


trace (my_color.brightOffset);

Description

The brightOffset property of the XColor object.


negative : Number

Usage


trace (my_color.negative);

Description

The negative property of the XColor object.


red : Number

Usage


trace (my_color.red);

Description

The red property of the XColor object.


green : Number

Usage


trace (my_color.green);

Description

The green property of the XColor object.


blue : Number

Usage


trace (my_color.blue);

Description

The blue property of the XColor object.


redPercent : Number

Usage


trace (my_color.redPercent);

Description

The redPercent property of the XColor object.


greenPercent : Number

Usage


trace (my_color.greenPercent);

Description

The greenPercent property of the XColor object.


bluePercent : Number

Usage


trace (my_color.bluePercent);

Description

The bluePercent property of the XColor object.


redOffset : Number

Usage


trace (my_color.redOffset);

Description

The redOffset property of the XColor object.


greenOffset : Number

Usage


trace (my_color.greenOffset);

Description

The greenOffset property of the XColor object.


blueOffset : Number

Usage


trace (my_color.blueOffset);

Description

The blueOffset property of the XColor object.