|
||||||
|
||||||
Flash Tutorial - Generating Random Numbers

Free
Flash Tutorial
ActionScript 2 Code Submitted by Alexander Kuzmin
If you are using AS2 you may wish to use an array. This cuts down on the length of the code:
on (release) {
//Sets the hellos.
var myHellos:Array = new Array("Hello", "Salut", "Guten Tag", "Hola");// Sets the number of digits in the random sequence:
var mySetting = 4;
// Creates a random number:
myNumber = random(mySetting);
//Checks the repeat function
while (myNumber == myTemp) {
myNumber = random(mySetting)+1;
}
// Resets the variable to the new random number:
myTemp = myNumber;//Takes the hello at that position in the array and uses it.
myDisplay = myHellos[myNumber];
}With Thanks: Code submitted by Alexander Kuzmin
Return to tutorial: Generating Random Numbers
I hope you have found this useful. If so perhaps you could recommend this site to others and link to webwasp!
Why not try out webwasp's new community. Meet new people, find friends in your area: Webwasp Mates & Dates
|
|
|
All material on this site is protected under international copyright © law. DO NOT reproduce any material from this site without written permission. Please ask as permission is often granted.
|