Merrill, Jason wrote:
If you're manipulating the number, as opposed to storing or displaying it,

Thanks, but yeah, the purpose is to display the hex #, the full 6
digits, to the user as #006699.  thanks though!


The function I included at the bottom should do that. I modified it to pad the output with a pound sign and leading zeroes.

//--------------------------
function decimalToHex(decVal:Number):String {
  var digits:String = "012345689ABCDEF";
  var returnStr:String = "";
  while (decVal) {
    returnStr += digits.substr(decVal & 15 -1, 1);
    decVal >>= 4;
  }
  return "#" + ("000000" + returnStr).substr(-6,6);
}

trace(decimalToHex(65535));

// outputs "#00FFFF"

//--------------------------


-Jim
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to