Packagegraphics.colors
Classpublic class RGBA
InheritanceRGBA Inheritance RGB Inheritance Object
Subclasses HTMLColor

The RGBA class encapsulates an rgba color.
     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]
     



Public Properties
 PropertyDefined By
  a : Number
The alpha component (between 0 and 1)
RGBA
 Inheritedb : uint
The blue component, between 0 and 255.
RGB
 Inheritedg : uint
The green component, between 0 and 255.
RGB
 Inheritedluminance : 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
 Inheritedr : uint
The red component, between 0 and 255.
RGB
Public Methods
 MethodDefined 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
  
interpolate(color:RGB, level:Number = 1):RGB
[override] Interpolate the color and returns a new RGB object.
RGBA
 Inherited
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
Protected Methods
 MethodDefined By
 Inherited
toHex(value:uint):String
Basic method use to convert the specified uint value in a hexadecimal String representation.
RGB
Property Detail
aproperty
a:Number

The alpha component (between 0 and 1)


Implementation
    public function get a():Number
    public function set a(value:Number):void
offsetproperty 
offset:Number

Defines the alpha component value with an offset representation (between 0 and 255)


Implementation
    public function get offset():Number
    public function set offset(value:Number):void
percentproperty 
percent:Number

Defines the alpha component value with a percent representation (between 0 and 100)


Implementation
    public function get percent():Number
    public function set percent(value:Number):void
Constructor Detail
RGBA()Constructor
public function RGBA(r:uint = 0, g:uint = 0, b:uint = 0, a:Number = 1)

Creates a new RGBA instance.

Parameters
r: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).
Method Detail
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():void

Transforms the red, green and blue components of the color in this difference color representation.

equals()method 
override public function equals(o:*):Boolean

Compares the specified object with this object for equality.

Parameters

o:*

Returns
Booleantrue if the the specified object is equal with this object.
fromNumber()method 
override public function fromNumber(value:Number):void

Sets the red, green and blue component with the specified number value.

Parameters

value:Number

fromNumber()method 
public static function fromNumber(value:Number):RGBA

Returns 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

Returns
RGBA — the object representation of the color number passed in argument.
interpolate()method 
override public function interpolate(color:RGB, level:Number = 1):RGB

Interpolate 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.

Returns
RGB — The interpolate RGB reference of the current color.
set()method 
override public function set(... args):void

Sets all foor components of a color.

Parameters

... args

toHexString()method 
override public function toHexString(prefix:String = 0x):String

Returns 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").

Returns
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):uint

Converts 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)

Returns
uint — the decimal number representation of the specified red, green, blue, alpha parameters.
toObject()method 
override public function toObject():Object

Returns the Object representation of the instance.

Returns
Object — the Object representation of the instance.
toSource()method 
override public function toSource(indent:int = 0):String

Returns the source code string representation of the object.

Parameters

indent:int (default = 0)

Returns
String — the source code string representation of the object.
toString()method 
override public function toString():String

Returns a String representation of the object.

Returns
String — a String representation of the object.
valueOf()method 
override public function valueOf():uint

Returns the real value of the object.

Returns
uint — the real value of the object.