微型抽奖as程序
//存放手机号的数组
var sj_array:Array = [1302323434, 1313544545, 133345454, 123345456, 154545645];
var num:Number = 0;
var add_num:Number = 0;
//这个数组只是存放几等奖的名称,没有实际意义
var xu_array:Array = ["一", "二", "三"];
//随机显示手机号
onEnterFrame = function () {
num = random(sj_array.length);
out_txt.text = sj_array[num];
};
//按钮一次按钮抽一次奖
x_btn.onRelease = function() {
add_num++;
jiang_txt.text += xu_array[add_num-1]+"等奖是:"+out_txt.text+"\r";
//关键在这里,把上面抽出的号码从数组中删除,它就不会再出现了
sj_array.splice(num, 1);
//如果已经抽出三个奖,就停止
if (add_num>=3) {
delete onEnterFrame;
out_txt.text = "抽奖完成!";
//既然抽奖完成,这个按钮也该让它失效了,嘿嘿~!!
this.enabled = false;
}
};