views:

132

answers:

1

Hi all, basically i want to build a colour hex value using 3 decimal values.

for clarities sake, the 3 decimals i have are

255 254 253

and i want to generate the hex string:

0xFFFEFD

how would i do that?

A: 
var red:int = 255;
var green:int = 254;
var blue:int = 253;

private function _getHexStringFromRGB($red, $green, $blue):String {
    var num:Number = ($red << 16) + ($green << 8) + $blue;
    return "0x" + num.toString(16).toUpperCase();
}

trace(getHexStringFromRGB(red, green, blue);

Bitwise shift

sberry2A