AS3: uint to hex


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



Copy this code and paste it in your HTML
  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. }

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.