you're problem is that alpha is in the top 8 bits. The leading bit of which represents the 'sign' of an int...
take:
0xFF000000
in binary is:
11111111 00000000 0000000 00000000
that first 1 there says it's a negative int... this is why ARGB is a uint, so that it isn't considered negative
There are two different 'right shifts'
>> - right shift
>>> - unsigned right shift
the second of which ignores the sign and just shifts...
next, we don't need to mask Alpha if we do unsigned right shift, because 0's get padded in...
the result is:
ActionScript Code:
function extractAlpha( value:uint ):uint
{
return value >>> 24;
}
I'm going to write a BitHelper class right now... for your consideration here is 5 basic functions for colours:
ActionScript Code:
package com.lordofduct.util
{
public class BitHelper
{
public function BitHelper()
{
}
/**
* ARGB Colour Helpers
*/
static public function colorsToARGB( r:int, g:int, b:int, alpha:int=0xFF ):uint
{
return (alpha << 24) | ((r & 0xFF) << 16) | ((g & 0xFF) << 8) | (b & 0xFF);
}
static public function extractAlpha( value:uint ):uint
{
return value >>> 24;
}
static public function extractRed( value:uint ):uint
{
return (value >> 16) & 0xFF;
}
static public function extractGreen( value:uint ):uint
{
return (value >> 8) & 0xFF;
}
static public function extractBlue( value:uint ):uint
{
return value & 0xFF;
}
}
}