PDA

View Full Version : lottery program



red_sun
12-11-2003, 02:26 AM
Hello,every one!
I want my flash to obtain the following effect. But I am in trouble.
There are two buttons and a dynamic text box in my flash.The two buttons are start and end button. When you click the start button,you will find the random data in the dynamic text box changing constantly until you click the stop button.
Can anyone help me, thanks a lot!

I do try it myself!
I am just learning how to use actionscript!

Below is the start button script!
Hit is a variable in the dynamic text box!

on (release) {
a = random(300);
switch (true) {
case (a>0 && a<10) :
hit = "00"+""+a;
break;
case (a>9 && a<100) :
hit = "0"+""+a;
break;
default :
hit = a;
break;
}
}
It produces only a number when you click start button once!
Originally,I use a while loop in the script above,but it seems the loop will never stop. Although a global variable in End button to indicate the loop condition is false!:(

blake
12-11-2003, 07:03 AM
Hey,
all you haft to do is make the start button into a movie clip,go inside it and add and give frame 2 this code

_root.a = random&#40;300&#41;;
switch &#40;true&#41; &#123;
case &#40;a>0 && a<10&#41; &#58;
hit = "00"+""+a;
break;
case &#40;a>9 && a<100&#41; &#58;
hit = "0"+""+a;
break;
default &#58;
hit = a;
break;
&#125;
gotoAndPlay&#40;2&#41;;

In that clip and give the start button a play script instead. On frame 3 of the new clip put gotoandplay frame 2 and on frame 1 put a stop() script.

Now on the main stage make a stop button and give it this code
on &#40;release&#41; &#123;
_root.otherbutton.gotoAndStop&#40;1&#41;;

&#125;


That should work, here the source file anyway!

cheers, Blake

[edit] i called the dynamic box "a" still works fine though...i didnt realise :oops:

red_sun
12-15-2003, 05:31 AM
Anyway,I thank you a lot!
I have work out it!Because I found tow useful functions,one is setInterval and another is clearInterval!