Flex 产生随机数、随机颜色

 //创建一个x~y之间的随机数(不包含y值),Math.round(Math.random() * (y - x)) + x;  

//0-5之间的随机数,不包含5
var index: Number = Math.round(Math.random() * 5);
var colors: Array = ["#FF00FF", "#0000FF", "#000000", "#008000", "#800000"];
color
= colors[index];

//15-25之间的随机数,不包含25
var index: Number = Math.round(Math.random() * (25 - 15)) + 15;

随机16进制颜色:Alert.show((Math.random()
* 0xffffff).toString(16));
color
= "#" + (Math.random()* 0xffffff).toString(16);
posted on 2011-09-05 11:37  hoojo  阅读(6317)  评论(0编辑  收藏  举报