# Place 35 movie clips in random order on stage in specific XY coordinates

**URL:** <https://forum.kirupa.com/t/place-35-movie-clips-in-random-order-on-stage-in-specific-xy-coordinates/299928>\
**Category:** flash\
**Created:** [November 12, 2009, 8:36pm UTC](https://forum.kirupa.com/t/place-35-movie-clips-in-random-order-on-stage-in-specific-xy-coordinates/299928 "2009-11-12T20:36:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mercuryfx](https://avatars.discourse-cdn.com/v4/letter/m/3ab097/32.png) [@mercuryfx](https://forum.kirupa.com/u/mercuryfx)\
**Post date:** [November 12, 2009, 8:36pm UTC](https://forum.kirupa.com/t/place-35-movie-clips-in-random-order-on-stage-in-specific-xy-coordinates/299928/1 "2009-11-12T20:36:06Z")

</div>

I have 35 movie clips named mcMyObject1, mcMyObject2, etc. to mcMyObject35

Each time the playhead enters the frame this code sits on, I want all of these 35 movie clips to be placed on the stage in random order

I want each one of these 35 movie clips to land on one of these X coordinates: 57, 187, 317, 447, 577, 707, 837 and on one of these Y coordinates: 53, 183, 131, 443, 573. (It’s a 7 x 5 grid)

Movie size is 1024 x 768

I need help. Thanks!  
Here’s my code, which doesn’t work:

stop();

var myXArray=[57, 187, 317, 447, 577, 707, 837]; //cordordinates for x  
var myYArray=[53, 183, 313, 443, 573, 573, 573]; //cordordinates for y  
var myArrayLength:Number=myXArray.length \* myYArray.length;

for (i=1; i\<=myArrayLength; ++i) {  
this[“mcFindObject”+1].Number=“mcFindObject”+(i+1);  
var setNewLocations = myXArray \* myYArray;  
}

trace(setNewLocations); //output says NaN

function setNewLocations() {  
myXArray.sort(shuffle);  
for (var j=1; j\<=myXArray.length; j++){  
this[“mcFindObject”+((i-1)\*7+j)].newXLoc=myXArray[i-1];  
this[“mcFindObject”+((i-1)\*5+j)].newYLoc=myYArray[j-1];  
}  
}

trace(myXArray.sort(shuffle));

for (i=1; i\<=myArrayLength; i++){  
this[“mcFindObject”+i].onEnterFrame=function(){  
this.\_x += (this.newXLoc - this.\_x);  
this.\_y += (this.newYLoc - this.\_y);  
};  
}

function shuffle(a,b):Number {  
return Math.floor(Math.random() \* 30) + 1; [//Math.floor](https://Math.floor) truncates the number  
//generated by Math.random to a whole number  
}
