# Random Array Element

**URL:** <https://forum.kirupa.com/t/random-array-element/310753>\
**Category:** flash\
**Created:** [June 18, 2010, 7:37am UTC](https://forum.kirupa.com/t/random-array-element/310753 "2010-06-18T07:37:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![DemonGibi](https://avatars.discourse-cdn.com/v4/letter/d/db5fbb/32.png) [@DemonGibi](https://forum.kirupa.com/u/DemonGibi)\
**Post date:** [June 18, 2010, 7:37am UTC](https://forum.kirupa.com/t/random-array-element/310753/1 "2010-06-18T07:37:21Z")

</div>

Hi there…  
I’m trying to create a list with an array…  
My purpose is to put array elements randomly in to the list…  
But the catch is, I want one array item to assign with 2 list objects…  
I mean…  
My arrray is : [“1”,“2”]  
And my list is this : “A”, “B”, “C”, “D”

“A1”, “B2”, “C2”, “D1”

The code below creates a box and gives an id to it from an array…  
But sometimes it gives the same array item to every box created…  
The problem is I just want the array item to be used only two times…  
What should I do?  
I hope I explained myself clearly 🙂

Thank you in advance…

```auto

private var boxCount : int = 4;
public var levelOneNumbers : Array = ["1", "2"];

for (var i:int = 0; i < boxCount; i++) 
                {
                    var box : MyBox = new MyBox;
                    for (var j:int = 0; j < box.levelOneNumbers.length; j++) 
                    {
                        box.id = box.levelOneNumbers[Math.floor(Math.random() * box.levelOneNumbers.length * j)];
                        
                        
                    }
                    
                    
                    box.x = (i * 60) + 100;
                    
                    addChild(box);
}

```
