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 truncates the number
//generated by Math.random to a whole number
}