AS3 Convert a Hex Value to RGB Using Bitwise Operators


/ Published in: ActionScript 3
Save to your folder(s)



Copy this code and paste it in your 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

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.