Posted By

adrianparr on 03/03/10


Tagged

base hex red convert and RGB bit shift bitwise as3 Blue Green


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

tspitzr


AS3 Convert a Hex Value to RGB Using Bitwise Operators


 / Published in: ActionScript 3
 

URL: http://theflashblog.com/presentations/bytearrays.html

  1. var colour:uint = 0x9900CC;
  2. var r:uint = colour >> 16;
  3. var g:uint = colour >> 8 & 0xFF;
  4. var b:uint = colour & 0xFF;
  5.  
  6. trace("r: "+r);
  7. trace("g: "+g);
  8. trace("b: "+b);
  9.  
  10. // OUTPUT
  11. // r: 153
  12. // g: 0
  13. // b: 204

Report this snippet  

You need to login to post a comment.