| Home | Tutorials | Forums | Articles | Blogs | Movies | Library | Employment | Press | Buy templates |
|
|
#1 |
|
Registered User
Join Date: Feb 2002
Posts: 2
|
I'm making a keno game and I need 20 random numbers, that do not repeat.
I'm new with arrays, and flash 5 scripting (Deleted Falsh 4) If someone could please help, I'll stop banging my head against the wall! Sammy myArray=(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16, 17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33 ,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,5 0,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66, 67,68,69,70,71,72,73,74,75,76,77,78,79); v = random(myarray)+1; tellTarget (this.v) { play (); } if (v<=40) { t = t+1; } else { b = b+1; } |
|
|
|
|
|
#2 |
|
Administrator
Join Date: Nov 2000
Location: Australia
Posts: 8,612
|
Here you go:
Code:
function ranNumArray (values, limit) {
var count = -1;
var numbers = new Array();
while (numbers.length<=values) {
var match = false;
count++;
var ran = random(limit);
for (var x = 0; x<=numbers.length; x++) {
if (ran == numbers[x]) {
match = true;
break;
}
}
if (!match) {
numbers[count] = ran;
} else {
count--;
}
}
return numbers;
}
trace (ranNumArray(20, 70));
__________________
Cheers Jesse Stratford ActionScript.org Cofounder Email: presented in this way to stop spam-bots: My email is composed of my first name (jesse) followed by my last name (stratford) followed by @ followed by actionscript.org Please don't email or PM me Flash questions, that's what the Forums are for! ![]() Please don't rely on me reading my PMs either. Email me about important stuff. |
|
|
|
|
|
|
|
|
#3 |
|
Registered User
Join Date: Feb 2002
Posts: 2
|
I am your humble servant from this day forward!
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to generate Random Questions for a game? | Blackshark | ActionScript 2.0 | 13 | 04-20-2007 04:42 AM |
| game with random sound clips | scott_allen13 | ActionScript 2.0 | 6 | 03-01-2005 07:11 PM |
| need decoder that will generate random 7 numbers with some fixed sum | devil | ActionScript 2.0 | 15 | 05-26-2004 02:00 PM |
| random numbers with no repeat | daspetey | ActionScript 2.0 | 2 | 02-19-2004 02:11 PM |
| Making random numbers | indiochano | Simple Stuff (Newbies) | 6 | 07-10-2003 12:10 AM |