To isolate the color channels and alpha channel from a 32-bit color we use shifting and bitwise AND operator.
var colorValue:uint = 0xFFFFCC99; // Isolate Alpha channel var alpha:uint = ( colorValue << 24 ) & 0xFF; // Isolate Red channel var red:uint = ( colorValue << 16 ) & 0xFF; // Isolate Green channel var green:uint = ( colorValue << 8 ) & 0xFF; // Isolate Blue channel var blue:uint = colorValue & 0xFF;
To clear just one channel (let say red) in a 32-bit color value you can do as below:
// Clearing the red channel colorValue &= 0xFF00FFFF;
Form more about this see Essential Actionscript 3.0 by Colin Moock, O’Reilly, chapter 26 - Bitmap Programming.
Tags: 32-bit, ActionScript, alpha channel, bitmap, channels, color
This post was written by Andrei Ionescu
Views: 709



















It should be right shift I believe. So in order to get the red value from ARGB color value ( a 8 byte uint).
// Isolate Red channel
var red:uint = ( colorValue >> 16 ) & 0xFF;
this is >> not <<
var colorValue:uint = 0xFFFFCC99;
So :
// Isolate Alpha channel
var alpha:uint = ( colorValue >> 24 ) & 0xFF;
etc…