Converting a uint from hex to argb in Flash

There are some functions in actionscript that take uint in the form of argb and hex. It took me a while to figure out why my fills where not visible!
 
For instance
fillRect(rect:Rectangle, color:uint):void
fills a rectangular area of pixels with a specified ARGB color.
and
 
beginFill(color:uint, alpha:Number = 1.0):void
Specifies a simple one-color fill that Flash Player uses for subsequent calls to other Graphics methods (such as lineTo() or drawCircle()) for the object.
 
The graphics.beginFill function will take a uint containing standard HTML hex colors such as 0xEEEEEE (grey) or 0xFFFFFF (white)
wheras the fillRect takes an ARGB value as a uint
0xFFEEEEEE ( grey with opaque alpha) or 0xFFFFFFFF ( white with opaque alpha).
 
Converting between the two is just a matter of adding or subtracting the alpha.
 
so a hex uint (grey) 0xEEEEEE + an argb  Alpha 0xFF000000  will give you the  proper ARGB value without any need for conversion or type castsing.
 
 I hope this helps someone out.


Reply

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You may link to Gallery2 items on this site using a special syntax.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.