# Array headache

**URL:** <https://forum.kirupa.com/t/array-headache/57273>\
**Category:** flash\
**Created:** [July 12, 2004, 12:35am UTC](https://forum.kirupa.com/t/array-headache/57273 "2004-07-12T00:35:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![worm](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/worm/32/235_2.png) [@worm](https://forum.kirupa.com/u/worm)\
**Post date:** [July 12, 2004, 12:35am UTC](https://forum.kirupa.com/t/array-headache/57273/1 "2004-07-12T00:35:38Z")

</div>

Im pretty much new to arrays and its killing me to figure some stuff out. I have the following script on the main timeline in my movie

```auto
Array.prototype.shuffle=function(){
   for(i=0;i<this.length;i++){
      var tmp=this*;
      var randomNum=random(this.length);
      this*=this[randomNum];
      this[randomNum]=tmp;
   }
}

// USAGE:

arr1=["a","b","c","d","e"];
arr1.shuffle();
trace(arr1);

```

much thanks to sephiroth for it. Anyways, i created a movie clip with a dynamic textbox in it which i was hoping could pull one of the values from the array. How do i do this?

I uploaded the fla so hopefully one of you guys could tell me where im going wrong

---

<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:** [July 12, 2004, 1:09am UTC](https://forum.kirupa.com/t/array-headache/57273/2 "2004-07-12T01:09:38Z")

</div>

once you’ve shuffled, you mean?

I believe you do something like this:

textbox.text = array[0];

I chose zero because it’s the first element of any array, but since you’ve shuffled, it shouldn’t matter what number you choose.

or… if you wanna be doubley (sp?) certain it’s random, you could use a random number as the index.

var randomNum = (Math.random() \* array.length);  
textbox.text = array(randomNum);

btw… I like the dragon’s blink. It’s great. 🙂 fyi, his ear-flap-thingy blinks out, you should fix that.

anyways… hope that helps. 🙂

---

<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:** [July 12, 2004, 4:36pm UTC](https://forum.kirupa.com/t/array-headache/57273/3 "2004-07-12T16:36:53Z")

</div>

Im not sure i understand something. Should i put this

```auto
textbox.text = array[0];

```

on the movie clip itself or in the ‘var’ section of the textbox properties.

---

<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:** [July 12, 2004, 4:52pm UTC](https://forum.kirupa.com/t/array-headache/57273/4 "2004-07-12T16:52:46Z")

</div>

Dont mind me, i figured it out. I put the code on the movie clip itself. Thanks Daheroes and shoutouts to Sephiroth.it for the killa script!!  
_insert gansta pose here_

---

<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:** [July 13, 2004, 5:18am UTC](https://forum.kirupa.com/t/array-headache/57273/5 "2004-07-13T05:18:51Z")

</div>

no prob. 🙂
