开发者

Actionscript Build Hex String

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开发者_JAVA百科?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜