About Hex Color Codes in Flex (AS3)


Hi folks,

I recognized a lot of views on the last post I made came from users searching for stuff like 0xFFFFFFFF color code or something in that manner. This made me suggest there are a lot of people who do not understand what this means to Flex/Flash using Actionscript 3. So here is a little explanation:

Imagine you’d have a color code like this:

0xFFFF0000

This means a full opaque red for Flex, because the whole color code can be splitted into 4 regions (called channels) : Alpha, Red, Green and Blue

So for our example above this means you’re having the following channel options:

Alpha = FF (100%)
Red = FF (100%)
Green = 00
Blue = 00

So if you want to have a full opaque Blue you would write:

0xFF0000FF

Alpha = FF (100%)
Red = 00
Green = 00
Blue = FF (100%)

Now if you want to bring in lesser opacity you just have to reduce the alpha value. So to get a half opaque Green you would write:

0x8800FF00

Alpha = 88 (50%)
Red = 00
Green = FF ( 100%)
Blue = 00

So the conclusion out of this is that you will get a bright fully opaque white with writing:

0xFFFFFFFF

And a fully transparent “black” (transparent is transparent, no matter which color you take) with the following:

0x00000000

Some people who have a good understanding of colors (not me) can mix nearly every color just by mixing the colors in their head. If you are not interested in that (like me) just take a color picker and look at the Hexadecimal Code of the color.

The above will help you to get deeper into making effects using the Bitmap and BitmapData class and their methods. You can see a really simple example in the last tutorial – it shows you how to take out specific colors from an Bitmap in Flex / Flash using Actionscript 3. So go and have some fun with Bitmaps and Colors !

About these ads
  1. Thanx fot this tutorial !

  2. Thanks for helping me understand this color format!

    • Rose
    • December 21st, 2010

    Very helpful! Thank you :)

    • Joey
    • June 24th, 2011

    Thank you, exactly what I was looking for!

    • tugBUT
    • July 31st, 2011

    Yay, I needed this xD

    • Dowlers
    • September 29th, 2011

    Thanks I was always stumped by this and it’s so simple!

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: