In my most recent Adobe Flex project, I am storing color in the database as a hexadecimal number. However, Flex’s color picker widget (mx:ColorPicker) stores color values in decimal format. Now, I could use PHP’s dechex() function to convert the number, but I’d much rather send the data over in the proper format. After much struggling, I came across the following solution (it’s ridiculously easy):
var decimalNumber:int = 123456; var someVal:String = decimalNumber.toString(16);
Apparently, passing a value of “16” to the toString function will convert a decimal number to hex. Go figure.