AS3 Hex Colour (uint) to RGB Colours (Object)


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



Copy this code and paste it in your HTML
  1. var brightPinkHex:uint = 0xFF32CC;
  2. var brightPinkRGB:Object = HexToRGB(brightPinkHex);
  3. trace(brightPinkRGB.r+ ", " + brightPinkRGB.g + ", " + brightPinkRGB.b);
  4.  
  5. function HexToRGB(value:uint):Object {
  6. var rgb:Object = new Object();
  7. rgb.r = (value >> 16) & 0xFF
  8. rgb.g = (value >> 8) & 0xFF
  9. rgb.b = value & 0xFF
  10. return rgb;
  11. }
  12.  
  13. // OUTPUT
  14. // 255, 50, 204

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.