To retrieve the value of a single channel from a 32-bit color value, we can use the right shift and bitwise AND operators together : Color « Graphics « Flash / Flex / ActionScript






To retrieve the value of a single channel from a 32-bit color value, we can use the right shift and bitwise AND operators together

 

package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){

        var colorValue:uint   = 0xFFFFCC99;  // A sample color
        var alpha:uint = (colorValue >> 24) & 0xFF;  // Isolate the Alpha channel
        var red:uint   = (colorValue >> 16) & 0xFF;  // Isolate the Red channel
        var green:uint = (colorValue >> 8) & 0xFF;   // Isolate the Green channel
        var blue:uint  = colorValue & 0xFF;          // Isolate the Blue channel
        
        trace(alpha, red, green, blue);  // Displays: 255 255 204 153

    
    }
  }
}

        








Related examples in the same category

1.Produces a number that is the effective result of inserting the hex value AA into an existing color value