/ Published in: ActionScript 3
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function decimalToHex($decimal:int, $padding:int = 2):String { var hex:String = Number($decimal).toString(16); while (hex.length < $padding) { hex = "0" + hex; } return hex.toUpperCase(); } var decimal:int = 163; trace("decimal: " + decimal); var hex:String = decimalToHex(decimal, 4); trace("hex: " + hex); // OUTPUT // decimal: 163 // hex: 00A3