-
Scene:
1, and the two dynamic text boxes are named show_txt and result _ txt respectively (show _ txt is used to display the random number result _ txt is used to display the extracted number).
2. Three buttons, named start_btn, next_btn and reset _ BTN respectively (start _ BTN means to start drawing numbers, next_btn continues to draw numbers, and reset _ BTN draws numbers again).
Code:
//Define the range for extracting numbers.
var Hao:Array = new Array();
for(var I:int = 1; I & lt49; i++)
{
Hao. Push (I)
}
var num:int = 0;
var add _ num:int = 0; //How many lucky draws?
//The extracted number classification
//Random display of the extracted numbers
var timer = new Timer( 100,0);
timer . addevent listener(timer event。 TIMER,TIMER handler);
timer . start();
//Start extracting numbers
start _ BTN . addevent listener(mouse event。 Click, yahohaf);
Function timerhandler (e: timerevent): void
{
//Get the length of Hao array, which is now 1000.
num = math . floor(math . random()* Hao . length);
show _ txt . text = Hao[num];
}
Function yaohaoF (event: MouseEvent):void
{
add _ num++;
//result_txt.text= "lucky number"+xu _ array [add _ num-1]+":"+math.floor (math.random () * hao.length)+"\ r";
Result_txt.text= "The extraction number is"+show _ txt.text+"\ r";
timer . stop();
//Here is the key. Delete the selected number from the array and it won't appear again.
Hao splice (No.,1); //Delete the selected number.
//49 Stop if it has been withdrawn.
if(add _ num & gt; 49)
{
timer . stop();
Show_txt.text = "All numbers have been extracted";
result _ txt.text =
start _ btn.enabled = false
next _ btn.enabled = true
}
}
next _ BTN . addevent listener(mouse event。 Click, nextf);
Function nextF (event: MouseEvent):void
{
timer . start();
result _ txt.text =
}
reset _ BTN . addevent listener(mouse event。 Click, resetf);
Function resetF (event: MouseEvent):void
{
timer . start();
start _ btn.enabled = true
next _ btn.enabled = false
add _ num = 0;
}