Posted By

mhulse on 02/08/10


Tagged

hex conversion as3 uint


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

adrianparr
tspitzr


AS3: uint to hex


 / Published in: ActionScript 3
 

URL: http://blog.rcq129.com/coding/as3-uint-to-hex/

  1. private function uint2hex(dec:uint):String {
  2.  
  3. // http://blog.rcq129.com/coding/as3-uint-to-hex/
  4.  
  5. var digits:String = "0123456789ABCDEF";
  6. var hex:String = '';
  7.  
  8. while (dec > 0) {
  9.  
  10. var next:uint = dec & 0xF;
  11. dec >>= 4;
  12. hex = digits.charAt(next) + hex;
  13.  
  14. }
  15.  
  16. if (hex.length == 0) hex = '0'
  17.  
  18. return hex;
  19.  
  20. }

Report this snippet  

You need to login to post a comment.