PDA

View Full Version : Duplicate Mc



jagunco
May 15th, 2003, 10:33 AM
hi, this code is an example:
for (i=1; i<=10; i++) {
_root.box.duplicateMovieClip( "box"+i, i);
_root["box"+i]. _x=_root["box"+i]. _x+20;
}

What I want to do is multiplicate a MC on the_x and if the_x, imagine, is bigger than 760 for exemple, it go down one rown and start again duplicating the mcīs

the code up, only putīs one copy of the MC more 20 px in front


thanks

boristheblade
May 16th, 2003, 06:14 PM
Basically you need two for loops to make rows of an object. This code should help you.



xBoxs = 6;
yBoxs = 6;
xSpace = 30;
ySpace = 30;
xMiddle = Stage.width/2;
yMiddle = Stage.width/2;
for(y=0; y<yBoxs; y++){
for(x=0; x< xBoxs; x++){
dag= attachMovie("box", "b"+i, i++);
trace(dag);
dag._x = (x-(xBoxs-1)/2)*xSpace+xmiddle;
dag._y = (y-(yBoxs-1)/2)*ySpace+ymiddle;

}
}

:)