Don’t go about writing your own decimal to hexadecimal converter. In AS3, the Number.toString(radix : Number) method is all that you need:

  1. var myDeci : Number = 16711680;
  2. var myHexa : String = myDeci.toString (16); // myHexa now holds "ff0000"

Note that you may still need to left pad the resulting value, if you’re operating with color triplets – as, for instance, 0 in decimal will still be "0" as a hexadecimal string, and not "000000".