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…
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);
}