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 examples


Flash / Flex / ActionScript examples » Graphics » Color »

 

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 >> 240xFF;  // Isolate the Alpha channel
        var red:uint   = (colorValue >> 160xFF;  // Isolate the Red channel
        var green:uint = (colorValue >> 80xFF;   // Isolate the Green channel
        var blue:uint  = colorValue & 0xFF;          // Isolate the Blue channel
        
        trace(alpha, red, green, blue);  // Displays: 255 255 204 153

    
    }
  }
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo Graphics
» Color