Hello there, an array question(help?)

Hi, I am wondering if any of you might have some advice toward solving a script problem I am having. I am trying to write a game. It should give the viewer 12 non duplicationg randomly choosen clips out of 24. this code is called from an empty clip on stage. So far all it gets me is the same card 12 times over and over.
Thank you


&nbsp &nbsp &nbsp &nbsp randomNum=random(possibleCards);
&nbsp &nbsp &nbsp &nbsp {
&nbsp &nbsp &nbsp &nbsp for(i=0;i<12;i++)
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp {
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp this.attachMovie(possibleCards[randomNum],“layOut”+i,i);
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp this[“layout”+i]._x=i*200;
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp this._xscale=25;
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp this._yscale=25;

&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp }

&nbsp &nbsp &nbsp &nbsp }


Are you sure that this random(possibleCards); command exists ? I don’t know, I thought it was supposed to be an integer.
pom 0]

well, it does work as it returns something. and according to what i read it should work. Of course I have been wrong before. I did try a number variable and an i variable w/no successful results

i think you want:

randomNum = random(possiblecards.length);

you’ll also probably want to remove the card from the array once it’s been chosen to avoid choosing it again:


that should happen sometime after you’ve attached the movie.

  • possibleCards.splice(randomNum,1);*

is “splice” a macro script?
<img src=http://www.ezboard.com/intl/aenglish/images/emoticons/embarassed.gif ALT=":o"> I don’t know that there is a “splice” macro script…

splice is an array method

ou I see…
thanks once again…

thank you, will give it a shot and hopefully it’ll work out.