Posted By

adrianparr on 11/01/11


Tagged

number hex decimal Value conversion as3


Versions (?)

AS3 Decimal To Hex


 / Published in: ActionScript 3
 

  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  

You need to login to post a comment.