Posted By

adrianparr on 02/09/11


Tagged

hex red colour color convert RGB as3 Blue Green uint bitwiseshift


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

jazzy_miles


AS3 RGB Colour to Hex Colour (uint)


 / Published in: ActionScript 3
 

  1. var magentaRed:int = 255;
  2. var magentaGreen:int = 0;
  3. var magentaBlue:int = 255;
  4. var magentaHex:uint = RGBToHex(magentaRed, magentaGreen, magentaBlue);
  5. trace("magentaHex: ", magentaHex);
  6.  
  7. function RGBToHex(r:int, g:int, b:int):uint
  8. {
  9. var hex:uint = r << 16 | g << 8 | b;
  10. return hex;
  11. }
  12.  
  13. // OUTPUT
  14. // 16711935

Report this snippet  

You need to login to post a comment.