I am a little late. But another way to make the script short:
function dec2hex(input:Number):String {
var hex:Number;
// var stgHex:String = uint(input).toString(16);
var stgHex:String = uint(input+0x1000000).toString(16).substr(1);
/*
while (stgHex.length < 6) {
stgHex = "0"+stgHex;
}
*/
stgHex = "0x"+stgHex;
return stgHex;
}
_____
Robert Leisle wrote:
Hi Jason,
Is something like this what you need?
function dec2hex(input):String {
var hex:Number;
var stgHex:String = uint(input).toString(16);
while (stgHex.length < 6){
stgHex = "0"+stgHex;
}
stgHex = "0x"+stgHex;
return stgHex;
}
function hex2dec(input):String {
return String(uint(input));
}
// test run
var decColor:Number = 102;
var hexColor:String = dec2hex(decColor);
trace("hex: "+hexColor);
trace("dec: "+hex2dec(hexColor));
--
Fumio Nonaka
http://www.FumioNonaka.com/
My books<http://www.FumioNonaka.com/Books/index.html>
Flash community<http://F-site.org/>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders