Random Numbers AS2
Random Numbers AS2
Out of context: Reply #7
- Started
- Last post
- 14 Responses
- kumori040
var myRandNum:Number = -1;
function findRandNum():Void {
var tempNum:Number = Math.floor(Math.max(0, Math.min(Math.random() * 100, 100)));if (tempNum >= (myRandNum - 10) && tempNum <= (myRandNum + 10)) {
trace("too close!");
findRandNum();
} else {
myRandNum = tempNum;
trace(myRandNum);
}
}- The first part of the function generates a random num between 0 - 100. The second determines if its 10 numbers too close to the first. Try it.kumori04