如何转换进制中的ActionScript3为十进制? [英] How to convert hex to decimal in Actionscript3?

查看:135
本文介绍了如何转换进制中的ActionScript3为十进制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何转换十六进制(字符串),以十进制(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为十进制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆