Fx{r} is trying to start the Fx{r} Community! Please join our group on Adobe Groups following this link: http://groups.adobe.com/groups/ab29539ab9.
Fx{r} is now on Twitter too. Follow us @ twitter.com/fx_r!
«
»

ActionScript

Retrieving channels from a 32-bit color

Andrei Ionescu | 24.10.07 | 2 Comments

Google Buzz

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.

Share and Enjoy:
  • Twitter
  • Google Buzz
  • LinkedIn
  • Google Bookmarks
  • del.icio.us
  • Digg
  • Sphinn
  • blogmarks
  • Reddit
  • StumbleUpon
  • Facebook
  • DZone
  • FriendFeed
  • Yahoo! Buzz
  • Yahoo! Bookmarks
  • Slashdot
  • MySpace
  • Add to favorites




Tags: , , , , ,

This post was written by Andrei Ionescu

Views: 2435

related

2 Comments

have your say

Add your comment below, or trackback from your own site. Subscribe to these comments.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

:

:


«
»