AS3 Decimal To Hex


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



Copy this code and paste it in your HTML
  1. function decimalToHex($decimal:int, $padding:int = 2):String {
  2. var hex:String = Number($decimal).toString(16);
  3. while (hex.length < $padding)
  4. {
  5. hex = "0" + hex;
  6. }
  7. return hex.toUpperCase();
  8. }
  9.  
  10. var decimal:int = 163;
  11. trace("decimal: " + decimal);
  12. var hex:String = decimalToHex(decimal, 4);
  13. trace("hex: " + hex);
  14.  
  15. // OUTPUT
  16. // decimal: 163
  17. // hex: 00A3

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.