Re: [Flashcoders] Random numbers list

2008-07-29 Thread Ron Wheeler
If you do not care if the sequences repeat, you could fill an array with the numbers from 1 to 100 arranged in a random order. When you want to grab 10, just pick a random integer between 0 and 89 and grab the block of 10 numbers following that point. This would charge a penalty once when you

RE: [Flashcoders] Random numbers list

2008-07-29 Thread Keith Reinfeld
yes like: allNumbers:Array = [ 0, 1, 2, 3, ..., 100 ]; tenNumbers:Array = []; public function getNumberIn():void{ var n:int = tenNumbers.splice( int( Math.random * 10 ), 1 ); tenNumbers.push( allNumbers.splice( int( Math.random * allNumbers.length ), 1 ) );

Re: [Flashcoders] Random numbers list

2008-07-29 Thread Helmut Granda
No, that is not the only way you can target a path in the MAC. for example I different projects some require to distribute the PPV classes with the project so i add the classes inside the same folder I am working on. /Application.as /src/ /src/ppvclasses Then in my application I just do: import

Re: [Flashcoders] Random numbers list

2008-07-29 Thread Helmut Granda
wrong thread... oh my and its only tuesday! On Tue, Jul 29, 2008 at 9:57 AM, Helmut Granda [EMAIL PROTECTED]wrote: No, that is not the only way you can target a path in the MAC. for example I different projects some require to distribute the PPV classes with the project so i add the classes

Re: [Flashcoders] Random numbers list

2008-07-29 Thread laurent
That's a good idea! Ron Wheeler a écrit : If you do not care if the sequences repeat, you could fill an array with the numbers from 1 to 100 arranged in a random order. When you want to grab 10, just pick a random integer between 0 and 89 and grab the block of 10 numbers following that

RE: [Flashcoders] Random numbers list

2008-07-29 Thread Jesse Graupmann
I'm sure this isn't needed by now, just thought I'd take it as a fun challenge. var rangeMin:int = 0; var rangeMax:int = 100; var rangeSample:int = 10; // copy var numbers:Array = []; // original values var numberList:Array = []; for ( var i:int = 0; i = (rangeMax - rangeMin); i++ )

Re: [Flashcoders] Random numbers list

2008-07-29 Thread Juan Pablo Califano
This is very similar to what other people have already said. Basically, you can have two lists: one acts as a pool from where you'll grab numbers, randomly; the other one is a sequence of unique numbers. First, you fill the pool with numbers that fall between some range. Then you take one of the

Re: [Flashcoders] Random numbers list

2008-07-28 Thread laurent
you could make a first array filled with all number from 0 to 100 and then you splice to any random index range between 0 and the new size of the array. You fill another array with the last spliced number. do I make sense ? cheers L Eduardo Barbosa a écrit : Hi all! What I am trying to

Re: [Flashcoders] Random numbers list

2008-07-28 Thread laurent
oops no i did not get you point actually.. hm...more complex...:) L Eduardo Barbosa a écrit : Hi all! What I am trying to figure out is this: How to generate a sequence of random numbers where the newest is always different from all the previous? I need to continuosly rewrite an array of 10

Re: [Flashcoders] Random numbers list

2008-07-28 Thread laurent
still it can be done like that you always keep the number of numbers between two arrays... and swap numbers from one to another, that your sure to neve have twice the same one yeah...! :] L Eduardo Barbosa a écrit : Hi all! What I am trying to figure out is this: How to generate a sequence

RE: [Flashcoders] Random numbers list

2008-07-28 Thread Steve Abaffy
Every time you generate a new random number go through the array and see if any match the new number if so generate a new one and check again, if not add it to the array. With only 10 numbers in the array it would check very fast so you wouldn't be taking a performance hit. -Original

Re: [Flashcoders] Random numbers list

2008-07-28 Thread Matt S.
Can numbers repeat? Is this a constant loop where, for instance, the number 12 could show up two times in twenty seconds? Or would you want 12 to show up once and then go out of circulation permanently? .m On Mon, Jul 28, 2008 at 5:42 PM, Eduardo Barbosa [EMAIL PROTECTED] wrote: Hi all! What

Re: [Flashcoders] Random numbers list

2008-07-28 Thread Eduardo Barbosa
Hi Matt, Yes numbers can and should repeat through time. They just cant be repeated within the sequence at a given discreet time. Makes sense? :) On Mon, Jul 28, 2008 at 11:15 PM, Matt S. [EMAIL PROTECTED] wrote: Can numbers repeat? Is this a constant loop where, for instance, the number 12

Re: [Flashcoders] Random numbers list

2008-07-28 Thread Eduardo Barbosa
Hi Laurent, Your first suggestion is a very simple and clever trick i'll definetely keep in mind for future situations. However for this second variation you mean that I: 1) pick the numbers out of array 1 and splice it 2) move those numbers into array 2 3) when the length of array 1 would be

Re: [Flashcoders] Random numbers list

2008-07-28 Thread Eduardo Barbosa
Hi Steve, That was actually my first thought. I had a while loop and inside a for ... in loop to iterate through the array to check if the number was already there. But then for some reason the script made flash unresponsive. However I just came up with this which seems to be working, but i'm

Re: [Flashcoders] Random numbers list

2008-07-28 Thread laurent
yes like: allNumber:Array = [ 0, 1, 2, 3, ..., 100 ]; tenNumbers:Array = []; public function getNumberIn():void{ var i:in = int( Math.random * allNumber.length ); tenNumbers.push( allNumber.splice( i, 1 ) ); } then I don't know how you pick up the number to pass from tenNumbers

Re: [Flashcoders] Random numbers list

2008-07-28 Thread laurent
or perhaps tenNumber[ tenNumbers.length ] is faster than tenNumbers.push() never know about that one...the second return something so perhaps its slower.. laurent a écrit : yes like: allNumber:Array = [ 0, 1, 2, 3, ..., 100 ]; tenNumbers:Array = []; public function getNumberIn():void{

Re: [Flashcoders] Random numbers list

2008-07-28 Thread laurent
yes like: allNumbers:Array = [ 0, 1, 2, 3, ..., 100 ]; tenNumbers:Array = []; public function getNumberIn():void{ var n:int = tenNumbers.splice( int( Math.random * 10 ), 1 ); tenNumbers.push( allNumbers.splice( int( Math.random * allNumbers.length ), 1 ) );