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
Tk1

onClipEvent(load)
{
possibleCards=[“card0”,“card1”,“card2”,“card3”,“card4”,“card5”,“card6”,“card7”,“card8”,“card9”,“card10”,“card11”,“card12”,“card13”,“card14”,“card15”,“card16”,“card17”,“card18”,“card19”,“card20”,“card21”,“card22”,“card23”,“card24”];

&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
Tk1

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:

possibleCards.splice(randomNum,1);

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…
thanks!!..

splice is an array method

ou I see…
thanks once again…

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