Posted By

adrianparr on 02/09/11


Tagged

css hex String red colour color RGB formatted as3 Blue Green


Versions (?)

AS3 RGB Colour to CSS Colour (String)


 / Published in: ActionScript 3
 

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

Report this snippet  

You need to login to post a comment.