| Package | graphics.colors |
| Class | public class RGBA |
| Inheritance | RGBA RGB Object |
| Subclasses | HTMLColor |
import graphics.colors.RGBA ;
trace("---- black") ;
var black:RGBA = new RGBA() ;
trace( "black : " + black ) ; // [RGBA r:0 g:0 b:0 a:1 hex:0xFF000000]
trace( "black.toHexString('#') : " + black.toHexString("#") ) ; // #FF000000
trace( "black.a : " + black.a ) ; // 1
trace( "black.r : " + black.r ) ; // 0
trace( "black.g : " + black.g ) ; // 0
trace( "black.b : " + black.b ) ; // 0
trace( "black.percent : " + black.percent ) ; // 100
trace( "black.offset : " + black.offset ) ; // 255
trace("---- red") ;
var red:RGBA = new RGBA(255 , 0 , 0 , 0.5 ) ;
trace( "red : " + red ) ; // [RGBA r:255 g:0 b:0 a:0.5 hex:0x7FFF0000]
trace( "red.a : " + red.a ) ; // 0.5
trace( "red.r : " + red.r ) ; // 255
trace( "red.g : " + red.g ) ; // 0
trace( "red.b : " + red.b ) ; // 0
trace( "red.percent : " + red.percent ) ; // 50
trace( "red.offset : " + red.offset ) ; // 127.5
trace("---- blue") ;
var blue:RGBA = new RGBA(92, 160, 205, 0.4) ;
trace( "blue : " + blue ) ; // [RGBA r:92 g:160 b:205 a:0.4 hex:0x665CA0CD]
trace( "blue.a : " + blue.a ) ; // 0.4
trace( "blue.r : " + blue.r ) ; // 92
trace( "blue.g : " + blue.g ) ; // 160
trace( "blue.b : " + blue.b ) ; // 205
trace( "blue.percent : " + blue.percent ) ; // 40
trace( "blue.offset : " + blue.offset ) ; // 102
blue.offset = 255 ;
trace( "blue : " + blue ) ; // [RGBA r:92 g:160 b:205 a:1 hex:0xFF5CA0CD]
blue.percent = 50 ;
trace( "blue : " + blue ) ; // [RGBA r:92 g:160 b:205 a:0.5 hex:0x7F5CA0CD]
blue.fromNumber( 0x23516D ) ;
trace( "blue : " + blue ) ; // [RGBA r:35 g:81 b:109 a:0 hex:0x0023516D]
| Property | Defined By | ||
|---|---|---|---|
| a : Number
The alpha component (between 0 and 1)
| RGBA | ||
![]() | b : uint
The blue component, between 0 and 255. | RGB | |
![]() | g : uint
The green component, between 0 and 255. | RGB | |
![]() | luminance : Number
Indicates the luminance of the color. | RGB | |
| offset : Number
Defines the alpha component value with an offset representation (between 0 and 255)
| RGBA | ||
| percent : Number
Defines the alpha component value with a percent representation (between 0 and 100)
| RGBA | ||
![]() | r : uint
The red component, between 0 and 255. | RGB | |
| Method | Defined By | ||
|---|---|---|---|
RGBA(r:uint = 0, g:uint = 0, b:uint = 0, a:Number = 1)
Creates a new RGBA instance. | RGBA | ||
clone():* [override]
Creates and returns a shallow copy of the object. | RGBA | ||
difference():void [override]
Transforms the red, green and blue components of the color in this difference color representation. | RGBA | ||
equals(o:*):Boolean [override]
Compares the specified object with this object for equality. | RGBA | ||
fromNumber(value:Number):void [override]
Sets the red, green and blue component with the specified number value. | RGBA | ||
fromNumber(value:Number):RGBA [static]
Returns the RGBA representation of the color number passed in argument. | RGBA | ||
[override]
Interpolate the color and returns a new RGB object. | RGBA | ||
![]() | interpolateToNumber(to:RGB, level:Number = 1):Number
Interpolate the color and returns the number rgb value. | RGB | |
set(... args):void [override]
Sets all foor components of a color. | RGBA | ||
toHexString(prefix:String = 0x):String [override]
Returns the full hexadecimal String representation of the color. | RGBA | ||
toNumber(r:uint = 0, g:uint = 0, b:uint = 0, a:Number = 1):uint [static]
Converts the red, green, blue, alpha values in a decimal number color value (base 10). | RGBA | ||
toObject():Object [override]
Returns the Object representation of the instance. | RGBA | ||
toSource(indent:int = 0):String [override]
Returns the source code string representation of the object. | RGBA | ||
toString():String [override]
Returns a String representation of the object. | RGBA | ||
valueOf():uint [override]
Returns the real value of the object. | RGBA | ||
| a | property |
a:NumberThe alpha component (between 0 and 1)
public function get a():Number public function set a(value:Number):void| offset | property |
offset:NumberDefines the alpha component value with an offset representation (between 0 and 255)
public function get offset():Number public function set offset(value:Number):void| percent | property |
percent:NumberDefines the alpha component value with a percent representation (between 0 and 100)
public function get percent():Number public function set percent(value:Number):void| RGBA | () | Constructor |
public function RGBA(r:uint = 0, g:uint = 0, b:uint = 0, a:Number = 1)Creates a new RGBA instance.
Parametersr:uint (default = 0) — The red component, an interger value between 0 and 255 (default 0).
| |
g:uint (default = 0) — The green component, an interger value between 0 and 255 (default 0).
| |
b:uint (default = 0) — The blue component, an interger value between 0 and 255 (default 0).
| |
a:Number (default = 1) — The alpha component, an interger value between 0 and 1 (default 1).
|
| clone | () | method |
override public function clone():*Creates and returns a shallow copy of the object.
Returns* — A new object that is a shallow copy of this instance.
|
| difference | () | method |
override public function difference():voidTransforms the red, green and blue components of the color in this difference color representation.
| equals | () | method |
override public function equals(o:*):BooleanCompares the specified object with this object for equality.
Parameters
o:* |
Boolean — true if the the specified object is equal with this object.
|
| fromNumber | () | method |
override public function fromNumber(value:Number):voidSets the red, green and blue component with the specified number value.
Parameters
value:Number |
| fromNumber | () | method |
public static function fromNumber(value:Number):RGBAReturns the RGBA representation of the color number passed in argument.
Example :
import graphics.colors.RGBA ;
var rgba:RGBA = RGBA.fromNumber( 0xFFEA6F51 ) ;
trace(rgba) ; // [RGB r:234 g:111 b:81 a:1 hex:0xFFEA6F51]
Parameters
value:Number |
RGBA — the object representation of the color number passed in argument.
|
| interpolate | () | method |
override public function interpolate(color:RGB, level:Number = 1):RGBInterpolate the color and returns a new RGB object.
Parameters
color:RGB — The RGB reference used to interpolate the current RGB object.
| |
level:Number (default = 1) — The level of the interpolation as a decimal, where 0 is the start and 1 is the end.
|
RGB — The interpolate RGB reference of the current color.
|
| set | () | method |
override public function set(... args):voidSets all foor components of a color.
Parameters
... args |
| toHexString | () | method |
override public function toHexString(prefix:String = 0x):StringReturns the full hexadecimal String representation of the color.
Parameters
prefix:String (default = 0x) — The optional expression to defines the prefix of the final String result (default "0x").
|
String — the full hexadecimal String representation of the color.
|
| toNumber | () | method |
public static function toNumber(r:uint = 0, g:uint = 0, b:uint = 0, a:Number = 1):uintConverts the red, green, blue, alpha values in a decimal number color value (base 10).
Example :
import graphics.colors.RGBA ;
var rgba:Number = RGBA.toNumber(170,170,170,0.6) ;
trace( rgba ) ; // 0x99AAAAAA
Parameters
r:uint (default = 0) — The red component (between 0 and 0xFF)
| |
g:uint (default = 0) — The green component (between 0 and 0xFF)
| |
b:uint (default = 0) — The blue component (between 0 and 0xFF)
| |
a:Number (default = 1) — The alpha component (between 0 and 1)
|
uint — the decimal number representation of the specified red, green, blue, alpha parameters.
|
| toObject | () | method |
override public function toObject():ObjectReturns the Object representation of the instance.
ReturnsObject — the Object representation of the instance.
|
| toSource | () | method |
override public function toSource(indent:int = 0):StringReturns the source code string representation of the object.
Parameters
indent:int (default = 0) |
String — the source code string representation of the object.
|
| toString | () | method |
override public function toString():StringReturns a String representation of the object.
ReturnsString — a String representation of the object.
|
| valueOf | () | method |
override public function valueOf():uintReturns the real value of the object.
Returnsuint — the real value of the object.
|