Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Actionscript flex: Converting # colors to uint

I'm working with several components that take color as a uint, but the colors I have are in the format of "#161616". I'm not sure what the relation between the 2 types of colors are or how to go from one to another.

It doesn't have to be an actionscript solution. I have only a small number of these colors, so can be done manually too.

like image 878
Daryl Avatar asked Mar 12 '10 19:03

Daryl


2 Answers

var color:uint = 0x161616;

Or, to convert them programmatically:

var s:String = "#161616";
var color:uint = uint("0x" + s.substr(1));
like image 76
Cory Petosky Avatar answered Oct 07 '22 17:10

Cory Petosky


Be aware that stylesheets in Flex want the color values in the form #FFFFFF ... NOT 0xFFFFFF. MXML element style properties don't care. Although when you start writing something like:

<mx:VBox backgroundColor="

the Intellisense prompts you for a uint value; if you go ahead and complete it like so

<mx:VBox backgroundColor="#FFFFFF"></VBox>

it will still make your backgroundColor the same as if you had written

<mx:VBox backgroundColor="0xFFFFFF"></VBox>
like image 42
Robusto Avatar answered Oct 07 '22 16:10

Robusto