如何转换十六进制(字符串),以十进制(INT)中的ActionScript3?
How to convert hex(in string) to decimal(int) in Actionscript3?
推荐答案数, INT 和 UINT 类有的toString()方法,它接受基数作为参数。
Number, int and uint class having toString() method which accept radix as arguments.
基数指定数字的基数(从2到36)用于数字到字符串的转换。如果不指定基数参数,默认值是10。
radix Specifies the numeric base (from 2 to 36) to use for the number-to-string conversion. If you do not specify the radix parameter, the default value is 10.
您可以转换像八进制,十六进制,二进制数,通过和uint类中的任何位置。
you can convert to any base like octal, hex, binary via Number and uint class.
更好的办法
VAR十进制:INT = parseInt函数(FFFFFF,16); //输出:16777215
var decimal:int = parseInt("FFFFFF",16); // output : 16777215
另一种方式
var hex:String = "0xFFFFFF";
VAR hexint:INT = INT(十六进制); //输出:16777215
var hexint:int = int(hex); // output : 16777215
就相当于
VAR hexint:INT = INT(十六进制)的ToString(10); //十进制转换
回到最初值:
var decimalStr:String = hexint.toString(16).toUpperCase(); // output : FFFFFF更多推荐
如何转换进制中的ActionScript3为十进制?
发布评论