I don’t have mx and can’t open the attached file but the code to duplicate is pretty straightforward in flash5
assume you want to make 150 balls from the MC instance “ball”
for (i=101;i<=250;i++) {
ball.duplicateMovieClip(“ball”+i,i)
}
this will create 150 clones of MC ball and give them the instance names ball151, ball152, ball153 … ball250
Why use values from 101 to 250 I hear you ask? Force of habit because invariably you’ll need to refer to the instances using a conditional for loop. If you know that your MC will always have a 3 digit identifier (which you’ll get from _name.substr(-3)) then it’s a lot easier to perform arithmetic operations.
So where were we? We’d just created 150 instances of ball and they’re all sitting on top of each other. But we want them all set out in a grid. No problem. Create an array containing the x and y coords of 150 clips. Sounds hellish - not really.
position one ball MC on the screen and add this code
onClipEvent (Load) {
trace(Math.floor(_x)+",“Math.floor(_y)”+",")
}
Now duplicate this clip 15 time (Ctrl+D) - tedious I know and align the clips vertically (Ctrl+K).
Next group these 15 clips (Marquee the Ctrl+G) and duplicate this group 10 times. Again align (Ctrl+K)
Then test (Ctrl+Enter)
You’ll get a nice long trace of 300 coords separated by commas. Hmm, looks a bit like an array, doesn’t it.
Select the trace (Ctrl+A) and copy it (Ctrl+C)
The define a new Array called something like coords
coords= new Array() and paste the trace between the () remembering to delete the comma after the last coord
Then finally all you need to do is place this code on the orignal instance instance of the movie clip and hide this clip off stage
onClipEvent (Load) {
if (_name!=“ball”) {
_x=_parent.coords.shift()
_y=_parent.coords.shift()
}
}
I’ve put the if in because I don’t want the original clip ball to reposition on stage because it won’t have a 3 letter numerical identifier.
I’m sure there’s a far more elegant way to do this in mx and doubtless someone post it …