hi,

im pretty new to actionscript, and this is really my first attempt at ever

coding in it... I'm trying to make a random number generator as coding

practice, and hitting some bumps.

i want the generator to generate numbers from a range. this range is declared

by the user in Input boxes.

the generator ignores the minimum number and generates below it, but will not

generate numbers above the highest number, which i find strange. here is the

code:

//Random Number Generator

//set variables. "min" = the text with instance name "minim". "max" = the text

with instance name "maxim"

var min = minim.text;

var max = maxim.text;

/*when button with instance name "go" is released, the funtion occurs.

This function generates a random number between "max" and "min"*/}

go.onRelease = function() {

out1.text = (Math.round(Math.random()*(max-min)));

};

/*when the button with instance name "end" is released, the function occurs.

This function clears all the textboxes listed (out1 to out21).

These are output textboxes that show the generated numbers*/

end.onRelease = function() {

out1.text = "";

out2.text = "";

out3.text = "";

out4.text = "";

out5.text = "";

out6.text = "";

out7.text = "";

out8.text = "";

out9.text = "";

out10.text = "";

out11.text = "";

out12.text = "";

out13.text = "";

out14.text = "";

out15.text = "";

out16.text = "";

out17.text = "";

out18.text = "";

out19.text = "";

out20.text = "";

out21.text = "";

};

(i am fully aware that i could have used an array to clear the textboxes...

but i dont know how to, lol. if you could explain, it would be greatly

appreciated.)

the .fla can be found http://www.yqcomputer.com/ %20numbers.fla

feel free to ask any questions. look forward to hearing from someone.

go.onRelease = function() {

var min = Number(minim.text);

var max = Number(maxim.text);

out1.text = min+(Math.round(Math.random()*(max-min)));

};

var min = Number(minim.text);

var max = Number(maxim.text);

out1.text = min+(Math.round(Math.random()*(max-min)));

};

end.onRelease = function() {

for(var i=1;i<=21;i++){

_root.text="" //<-- if your textfields are on the _root timeline.

}

};

for(var i=1;i<=21;i++){

_root.text="" //<-- if your textfields are on the _root timeline.

}

};

thanx, erm, would you mind explaining what the code:

for(var i=1;i<=21;i++){

_root.text="" //<-- if your textfields are on the _root timeline.

}

};

actually does? thanx a whole lot!

for(var i=1;i<=21;i++){

_root.text="" //<-- if your textfields are on the _root timeline.

}

};

actually does? thanx a whole lot!

that clears your textfields _root.out1, _root.out2 etc. flash uses brackets to

resolve strings into objects (if they exist). so,

"out"+1 is

"out1" and the string "out1" flash can resolve to an object if you use

brackets:

_root is

_root.out1

resolve strings into objects (if they exist). so,

"out"+1 is

"out1" and the string "out1" flash can resolve to an object if you use

brackets:

_root is

_root.out1

thanks a lot! i finished it now, check it out http://www.yqcomputer.com/ , if you like.

(i edited the code you gave me to clear all the boxes, to make it generate to all boxes as well)

(i edited the code you gave me to clear all the boxes, to make it generate to all boxes as well)

1. Math.random() and Math.round(Math.random()) and Math.floor(Math.random()*2)

2. Math.random() and Math.round(Math.random()) and Math.floor(Math.random()*2)

3. math.round and math.ceil etc. do not work in flash 8!

4. Is there a way to have math that is not "display math" look like display math?

5. FA: 1-Day-Left: 6 Math Books - 4 Math CDROMs - Algebra, Discrete Math, Calculus, more...

6. Is there a way to have math that is not "display math" look like ?display math?

7. Math::GMP tests and Crypt::Random fail on Compaq (Math::Pari related ??)

8. Is there a way to have math that is not "display math" look like display math?

9. Error on Book: Advanced Eng Math using Math and Matlab ???

10. How do I use math.round to round a number to 3 decimal points?

11. How do I use math.round to round a number to 3 decimal points?

13. Math.Round and SQL Server Round

14. random number generator of Math.random() ?

15. Subclassing 'Math::BigFloat' gives 'Unknown round mode' error

7 post • Page:**1** of **1**