|
主题: 十进制和十六进制
|
 realbobo
职务:普通成员
等级:1
金币:1.0
发贴:180
注册:2002/3/5 12:32:45
|
#12002/4/1 19:03:03
在flash中怎么将十进制数转换为十六进制呢? 比如把random(255)转换成十六进制. 赐教谢谢
|
 Demon.S
职务:版主
等级:5
金币:10.0
发贴:2468
注册:2000/9/15 13:56:49
|
#22002/4/2 10:32:50
parseInt
|
 realbobo
职务:普通成员
等级:1
金币:1.0
发贴:180
注册:2002/3/5 12:32:45
|
#32002/4/2 11:41:40
这个好象只能把十六进制转换成十进制啊?
|
 Demon.S
职务:版主
等级:5
金币:10.0
发贴:2468
注册:2000/9/15 13:56:49
|
#42002/4/2 17:49:15
c=Math.floor(Math.random()*255)+1; b=Math.floor(Math.random()*255)+1; a=Math.floor(Math.random()*255)+1; result=c<<16|b<<8|a; D  S
|
 -=胡子=-
职务:普通成员
等级:1
金币:0.0
发贴:200
注册:2002/3/14 11:35:27
|
#52002/4/2 18:46:39
画魔在上个帖子中说 引用: c=Math.floor(Math.random()*255)+1; b=Math.^
D S
可以讲一讲关于进制的问题吗?比如,怎么用<<等移位操作符??造成什么后果??请赐教/
|
 暴雨
职务:普通成员
等级:1
金币:1.0
发贴:178
注册:2002/4/2 0:43:51
|
#62002/4/2 22:26:29
c = random (0xff); b = random (0xff); a = random (0xff); result = c << 16 | b << 8 | a;
|
 realbobo
职务:普通成员
等级:1
金币:1.0
发贴:180
注册:2002/3/5 12:32:45
|
#72002/4/3 8:41:44
ok!谢谢大家的帮忙,我也搞到一个方法。 a=random(255).toString(16); thank you all the same!
|
 暴雨
职务:普通成员
等级:1
金币:1.0
发贴:178
注册:2002/4/2 0:43:51
|
#82002/4/3 8:57:04
realbobo在上个帖子中说 引用: ok!谢谢大家的帮忙,我也搞到一个方法。 a=random(255).toString(16); thank you all the same!
Number.tostring()返回值是字符串,你需要的是字符串吗?
|
 千风子
职务:普通成员
等级:1
金币:0.0
发贴:18
注册:2001/7/28 20:30:27
|
#92002/4/3 21:11:38
暴雨在上个帖子中说 引用: realbobo在上个帖子中说 引用: ok!谢谢大家的帮忙,我也搞到一个方法。 a=random(255).toString(16); thank you all the same!
Number.tostring()返回值是字符串,你需要的是字符串吗?
number 和字符串 有多大的区别?!
|
 暴雨
职务:普通成员
等级:1
金币:1.0
发贴:178
注册:2002/4/2 0:43:51
|
#102002/4/3 22:37:57
千风子在上个帖子中说 引用: 暴雨在上个帖子中说 引用: realbobo在上个帖子中说 引用: ok!谢谢大家的帮忙,我也搞到一个方法。 a=random(255).toString(16); thank you all the same!
Number.tostring()返回值是字符串,你需要的是字符串吗?
number 和字符串 有多大的区别?!
Number对象是数值型数据的简单封装对象, 这意味着可以使用Number对象相关的方法和属性操作原始数值. 此函数提供的功能与javascript的 Number 对象相同 有多大的区别?——本质的区别。二者是截然不同的数据类型。比较一下下面两段代码,可以看出二者的区别: (1) on (release) { ccol = new Color(_root.aa); ccol.setRGB( 0xFF0000 ); } (2) on (release) { ccol = new Color(_root.aa); ccol.setRGB("0xFF0000" ); }
|
 realbobo
职务:普通成员
等级:1
金币:1.0
发贴:180
注册:2002/3/5 12:32:45
|
#112002/4/4 8:53:10
其实我就是需要一个随机颜色,不管是字串还是number都能达到效果。
|
 暴雨
职务:普通成员
等级:1
金币:1.0
发贴:178
注册:2002/4/2 0:43:51
|
#122002/4/4 10:19:59
那么试试下面的: ccol = new Color(_root.aa); rancolor = random(0xFFFFFF)+0x999999; ccol.setRGB(rancolor);
|
 realbobo
职务:普通成员
等级:1
金币:1.0
发贴:180
注册:2002/3/5 12:32:45
|
#132002/4/5 8:00:52
ok!thank you! 但是哪个random(0xffffff)后边加的0x999999是什么意思啊?
|
 暴雨
职务:普通成员
等级:1
金币:1.0
发贴:178
注册:2002/4/2 0:43:51
|
|