Packagecom.desuade.utils
Classpublic class ColorHelper
InheritanceColorHelper Inheritance Object

Language Version : ActionScript 3
Since : 18.04.2009
Runtime Versions : AIR 1.0, Flash Player 9.0.0

This is a static class that provides methods to help with tweening and working with colors.



Public Methods
 MethodDefined By
  
cleanColorValue(rgb:*):uint
[static] Takes any kind of color representation and makes it into a clean uint.
ColorHelper
  
decToHexString(dec:int):String
[static] Converts a decimal to a String-based hex
ColorHelper
  
getColorObject(type:String, amount:Number = 1, rgb:* = null, cco:Object = null):Object
[static] This returns an object used for color transformations.
ColorHelper
  
hexStringToDec(hex:String):int
[static] Converts a String-based hex value into a decimal
ColorHelper
  
hexToRGB(color:*):Object
[static] Creates an rgb object from a hex value
ColorHelper
  
RGBToHex(r:int, g:int, b:int):uint
[static] Takes a red, blue, and green and converts into a uint hex value
ColorHelper
Method Detail
cleanColorValue()method
public static function cleanColorValue(rgb:*):uint

Takes any kind of color representation and makes it into a clean uint.

Parameters

rgb:* — Any kind of color value - ie: "#FFFF00", "DDDDDD", 0xf7f7f7, 108475

Returns
uint — A uint that's a clean hex value
decToHexString()method 
public static function decToHexString(dec:int):String

Converts a decimal to a String-based hex

Parameters

dec:int — A decimal to convert - ie: 104901

Returns
String — A string version of the hex value - ie: "FF00AA"

See also

getColorObject()method 
public static function getColorObject(type:String, amount:Number = 1, rgb:* = null, cco:Object = null):Object

This returns an object used for color transformations. This is mostly used for ColorTweening.

There are a number of "types" to choose from:

brightness: amt:-1=black, 0=normal, 1=white brightOffset: amt:-1=black, 0=normal, 1=white contrast: amt:0=gray, 1=normal, 2=high-contrast, higher=posterized invert: amt:0=normal, .5=gray, 1=photo-negative tint: amt:0=none, 1=solid color (>1=posterized to tint, <0=inverted posterize to tint) clear: clears and clears the object

Parameters

type:String — What type of color transformation to perform. See above for a list of available types.
 
amount:Number (default = 1) — How much of the transformation to perform (0-1). This varies for each type.
 
rgb:* (default = null) — A color value - ie: "#FF00AA"
 
cco:Object (default = null) — This is the base (current) transformation object to use. For example, the current ColorTransformation of a MovieClip.

Returns
Object — A color transformation object.
hexStringToDec()method 
public static function hexStringToDec(hex:String):int

Converts a String-based hex value into a decimal

Parameters

hex:String — A string-hex value - ie: "FF00AA"

Returns
int — A decimal equivalent as an int - ie: 104901

See also

hexToRGB()method 
public static function hexToRGB(color:*):Object

Creates an rgb object from a hex value

Parameters

color:* — A color such as 0xff0044 or "#FF00FF"

Returns
Object — An object containg r,g,b - ie: {r:0, g:0, b:0}

See also

RGBToHex()method 
public static function RGBToHex(r:int, g:int, b:int):uint

Takes a red, blue, and green and converts into a uint hex value

Parameters

r:int — Red value 0-255
 
g:int — Green value 0-255
 
b:int — Blue value 0-255

Returns
uint — A uint hex value

See also