Some favorite site feeds aggregated locally: iPhone Development RSS   Adobe Labs RSS   Macrumors RSS

Wednesday, February 20, 2008

AS3 Color (TextFormat)

Wednesday, February 20, 2008   

I am applying a color (white) to a field in a class. Simple enough.
white = new TextFormat();
white.color = 0xFFFFFF;
Now later on, I flip through the DisplayObject looking for that value. I never find it, but tracing shows me what value I should be looking for.
var nCount:Number = container.numChildren;
for ( var i:Number = 0; i < nCount; i++ )
{
var curSprite = container.getChildAt( i );
trace( i, curSprite.label_txt.getTextFormat().color );
...
So what gets traced? The value: 16777215. I am assuming that 2 extra digits in there are translations of the alpha value. However, it still seems a little strange... but I am no mathematician or color theorist. I'm sure its correct, and I know what to look for, but I don't know exactly why yet ;) Magic numbers to me at the moment.
 
 Return to the main page
Comments:

There are currently 3 Comments:

Anonymous Anonymous said...
“If you are on a mac, open up the Calculator application, flip the view to "Programmer", then choose the HEX toggle in upper right. Type 0xFFFFFF..you'll see the decimal conversion of the hex value (by choosing DEC toggle in upper right), is 16777215.”
 
Blogger e.dolecki said...
February 20, 2008 4:57 PM
“Ah man... right. I was expecting something back in HEX. Thats a great tip there, thanks!!”
 
Anonymous Paulius Uza said...
February 20, 2008 5:20 PM
“You can trace it as hexadecimal value by using "color_string.toString(16);"

Glad to see you finally working with AS3!”
 
 Leave a comment