Let’s say I have an array with 7 elements in it.
I want to create a new array of 15 elements, randomly picked from the first array. Also, I want to have at least 1 of every element of the first array in the second array.
How can I achieve this?
This is what I already have:
pageArray= new Array("faces", "days", "sounds", "words", "wires", "arts", "thoughts");
objectsInScene = new Array();
for (i=1; i<=15; i++){
attachedObj = theScene.attachMovie(pageArray[Math.round(Math.random()*7)], "page"+i, theScene.depth++);
attachedObj.x = random(2500);
attachedObj.y = random(2500);
attachedObj.z = i*1000;
attachedObj.onPress = selectStar;
attachedObj.display = displayStar;
objectsInScene.push(attachedObj);
attachedObj.col = new Color(attachedObj);
};