Bitwise operations rely at the core of any programming language and are the fastest operations ever.
In this article I will dig into a practical procedure which is often used by digital artists and simple programmers.

Often you need to extract Red, Green and Blue (and sometime Alpha) components of an hexadecimal color value. To do this you must execute a simple operation:

```
// a color value can be of 24bit - RGB
var color:uint = 0x336699
var r:uint = color >> 16
var g:uint = color >> 8 & 0xFF
var b:uint = color & 0xFF

// or 32bit - ARGB, first one is Alpha
var color:uint = 0xff336699
var a:uint = color >>> 24
var r:uint = color >>> 16 & 0xFF
var g:uint = color >>>  8 & 0xFF
var b:uint = color & 0xFF
```

Next operation is combining the separated values into a hexadecimal color value:

```
//24bit
var r:uint = 0x33;
var g:uint = 0x66;
var b:uint = 0x99;
var color:uint = r << 16 | g << 8 | b;

//32bit
var a:uint = 0xff;
var r:uint = 0x33;
var g:uint = 0x66;
var b:uint = 0x99;
var color:uint = a << 24 | r << 16 | g << 8 | b
```

If you want to add an Alpha channell to some color you can use this function:

```
private function returnARGB(rgb:uint, newAlpha:uint):uint{
//newAlpha has to be in the 0 to 255 range
var argb:uint = 0;
argb += (newAlpha<<24);
argb += (rgb);
return argb;
}
```

if you want to convert a number in hexadecimal system to decimal or inverse use this methods:

```
var tt:uint = 0x18
trace( tt.toString(10) ) // traces 24

var tt:uint = 24
trace( tt.toString(16) ) // traces 18, not 0x18. But if we want to write a hexadecimal number
we must explicitly write 0x18
```

You can find more usefull info at
http://www.zedia.net/2008/converting-a-rgb-color-and-alpha-to-argb-in-actionscript-3/
http://en.wikipedia.org/wiki/Bitwise_operation