[FMX] Help working out/learning lottery script

Hey all,

Recently I started a thread about a lottery draw and got a good response that helped me out thanks to Adam14 and Kode.

http://www.kirupaforum.com/forums/showthread.php?t=52438
[url=“http://www.kirupaforum.com/forums/showthread.php?t=52438”]
Kode gave a basic file that included a random number draw and a ‘bank’ that payed out if lotto balls were correct.

My problem is the script is rather advanced and just passes over my head and I am still an newbie at action script, I would be very grateful if anyone could help explain/comment the script. User ‘Futureflash’ has added some parts.

The basic file is attached and script is below.
[url=“http://www.kirupaforum.com/forums/newthread.php?do=newthread&f=9”]
[color=black][font=Verdana]
[/font][/color][color=black][font=‘Trebuchet MS’]function resetLotto(reset)[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]{for (var prop in output) [/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]{output[prop].text = “?”;[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]}[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]status.htmlText = “<p align=“center”><a href=“asfunction:playLotto”>Click here to play!</a></p>”;[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]clearInterval(id);[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]}[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]function playLotto() {[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]var prop, numbers, index, ran; ‘variables[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]Message.text = “”; ‘clears the message box from any message displayed out[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]for (prop in input) { [/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]if (!input[prop].length) { [/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]message.htmlText = “<p align=“center”>Enter a number in all the fields!</p>”; ‘ Displays out message, why htmlText[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]id = setInterval(resetLotto, interval); ’[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]return; ‘not sure, going by the message a check to ensure all input boxes have values[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]}[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]}[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]numbers = []; [/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]for (index=1; index<=maxvalue; index++) { [/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]numbers.push(index); ‘ not sure[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]}[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]for (index=0; index<output.length; index++) { [/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]ran = Math.floor(Math.random()*numbers.length); [/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]output[index].text = numbers[ran]; ‘not sure[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]numbers.splice(ran, 1); ‘ not sure[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]}[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]for (index=0; index<output.length; index++) {[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]if (input[index].text != output[index].text) {[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]status.htmlText = “<p align=“center”>You’ve lost!</p>”; 'Displays out loosing message, any reason for html??[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]id = setInterval(resetLotto, interval);[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]return;[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]}[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]}[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]Message.htmlText = “<p align=“center”><b>You’ve won!</b></p>”; displays out winning message,any reason for html??[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]}[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]var id, interval = 2000; ‘ Variables and sets the interval to 2 seconds ???[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]var maxvalue = 49; ‘Set the maximum value[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]var output = [output0, output1, output2, output3, output4, output5]; ‘ Sets variables out for the text boxes[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]var input = [input0, input1, input2, input3, input4, input5]; ‘ Sets variables out for the text boxes[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]for (var prop in input) {[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]input[prop].restrict = “0-9”;[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]input[prop].onChanged = function() {[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]var n = parseFloat(this.text);[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]if (!isNaN(n) && n>maxvalue) {[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]this.text = maxvalue;[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]}[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]};[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]}[/font][/color][color=black][font=‘Trebuchet MS’]

[/font][/color][color=black][font=‘Trebuchet MS’]resetLotto();[/font][/color][color=black][font=Verdana][/font][/color]

[font=Times New Roman][size=3] [/size][/font]