ColorUtil
Kind of class: | class |
---|---|
Inherits from: | none |
Version: | 04/02/07 |
Author: | Aaron Clinger |
Classpath: | org.casalib.util.ColorUtil |
File last modified: | Monday, 01 December 2008, 13:34:40 |
Provides utility functions for dealing with color.
Summary
Class methods
- getRGBFromHex (colorHex:Number) : Object
- Converts a color in hexadecimal format into an RGB object.
- getHexStringFromRGB (r:Number, g:Number, b:Number) : String
- Converts a RGB color into a hexadecimal color string.
- getHexFromRGB (r:Number, g:Number, b:Number) : Number
- Converts a RGB color into a hexadecimal color number.
- setTint (target_mc:MovieClip, tintColor:Number, percent:Percent) : Void
- Specifies the tint color and tint percentage of a MovieClip.
Class methods
getHexFromRGB
static function getHexFromRGB (
r:Number,
g:Number,
b:Number) : Number
Converts a RGB color into a hexadecimal color number.
Parameters:
r:
The number value of red.
g:
The number value of green.
b:
The number value of blue.
Returns:
- Returns a hexadecimal color as a number.
Example:
-
trace(ColorUtil.getHexFromRGB(255, 0, 255));
getHexStringFromRGB
static function getHexStringFromRGB (
r:Number,
g:Number,
b:Number) : String
Converts a RGB color into a hexadecimal color string.
Parameters:
r:
The number value of red.
g:
The number value of green.
b:
The number value of blue.
Returns:
- Returns a hexadecimal color as a string.
Example:
-
trace(ColorUtil.getHexStringFromRGB(255, 0, 255));
getRGBFromHex
static function getRGBFromHex (
colorHex:Number) : Object
Converts a color in hexadecimal format into an RGB object.
Parameters:
colorHex:
The hexadecimal color.
Returns:
- Returns an object with the properties r, g and b defined.
Example:
-
var myRGB:Object = ColorUtil.getRGBFromHex(0xFF00FF); trace("Red = " + myRGB.r); trace("Green = " + myRGB.g); trace("Blue = " + myRGB.b);
setTint
Specifies the tint color and tint percentage of a MovieClip.
Parameters:
target_mc:
The MovieClip to tint.
tintColor:
The hexadecimal color to be set.
percent :
The tint percentage, from transparent to completely saturated.
Example:
-
ColorUtil.setTint(myMovie_mc, 0xFF00FF, new Percent(.8));