# Hello there, an array question(help?)

**URL:** <https://forum.kirupa.com/t/hello-there-an-array-question-help/3436>\
**Category:** Uncategorized\
**Created:** [February 2, 2002, 5:45pm UTC](https://forum.kirupa.com/t/hello-there-an-array-question-help/3436 "2002-02-02T17:45:33Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 2, 2002, 5:45pm UTC](https://forum.kirupa.com/t/hello-there-an-array-question-help/3436/1 "2002-02-02T17:45:33Z")

</div>

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 }

}

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 2, 2002, 5:51pm UTC](https://forum.kirupa.com/t/hello-there-an-array-question-help/3436/2 "2002-02-02T17:51:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 2, 2002, 6:29pm UTC](https://forum.kirupa.com/t/hello-there-an-array-question-help/3436/3 "2002-02-02T18:29:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 2, 2002, 7:33pm UTC](https://forum.kirupa.com/t/hello-there-an-array-question-help/3436/4 "2002-02-02T19:33:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 2, 2002, 8:15pm UTC](https://forum.kirupa.com/t/hello-there-an-array-question-help/3436/5 "2002-02-02T20:15:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 2, 2002, 8:46pm UTC](https://forum.kirupa.com/t/hello-there-an-array-question-help/3436/6 "2002-02-02T20:46:02Z")

</div>

splice is an array method

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 3, 2002, 8:38am UTC](https://forum.kirupa.com/t/hello-there-an-array-question-help/3436/7 "2002-02-03T08:38:52Z")

</div>

ou I see…  
thanks once again…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 3, 2002, 8:28pm UTC](https://forum.kirupa.com/t/hello-there-an-array-question-help/3436/8 "2002-02-03T20:28:10Z")

</div>

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