AS3 RGB Colour to Hex Colour (uint)


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



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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.