Quick Tip: uint To 6 Digit RGB Hex

Shortest possible, simple / no looping method of getting hex string from color is:

var color:uint = 0x00ff00;
var hex:String = color.toString(16);

trace("00000".substr(0, 6 - hex.length) + hex);
// output 00ff00

trace("#00000".substr(0, 7 - hex.length) + hex);
// output #00ff00

Leave a comment

Please be polite and on topic. Your e-mail will never be published.