# duplicateMovieClip Issues

**URL:** <https://forum.kirupa.com/t/duplicatemovieclip-issues/34042>\
**Category:** flash\
**Created:** [October 27, 2003, 12:29pm UTC](https://forum.kirupa.com/t/duplicatemovieclip-issues/34042 "2003-10-27T12:29:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![RaraAvis](https://avatars.discourse-cdn.com/v4/letter/r/4bbf92/32.png) [@RaraAvis](https://forum.kirupa.com/u/RaraAvis)\
**Post date:** [October 27, 2003, 12:29pm UTC](https://forum.kirupa.com/t/duplicatemovieclip-issues/34042/1 "2003-10-27T12:29:42Z")

</div>

Okay, so what I want is a set of 5 boxes.  
I want these boxes arranged 2 per row, so there should be 3 rows in total with the last row only having 1 box in it.

```auto

  [] []
  [] []
  []

```

Exactly like the above example.

Now I’m doing this by duplicating the 1 mc 5 times, here is my code:

```auto

onClipEvent(enterFrame) {
        var i = 1
        var ctr = 1
        
        while (i < 5) {
                
                if (ctr = 1) {
                        
                        mctemp = _root.picture1.duplicateMovieClip(i, i);
                        mctemp._x = 300;
                        i++;
                        ctr = 2;
                }
                else {
                        
                        mctemp = _root.picture1.duplicateMovieClip(i, i);
                        mctemp._x = 43;
                        mctemp._y = 100;
                        i++;
                        ctr = 1;
                        
                }
                
        }
        
}

```

And all I get is out put is the first row of boxes…

ie:

```auto

  [] []

```

and no more. Can anyone see the error in my code?

Thanks in advance guys,  
RaraAvis

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 27, 2003, 12:39pm UTC](https://forum.kirupa.com/t/duplicatemovieclip-issues/34042/2 "2003-10-27T12:39:05Z")

</div>

Here’s some working code, place it on the timeline in which your movieclip is in.

```auto

box._visible = 0;
spacing = {x:100, y:100};
for (i=1; i<=5; i++) {
	mc = box.duplicateMovieClip("box"+i, i);
	i%2 == 0 ? mc._x=box._x+spacing.x : mc._x=box._x;
	i<=2 ? mc._y=box._y : i>4 ? mc._y=box._y+(2*spacing.y) : mc._y=box._y+spacing.y;
}

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 27, 2003, 12:43pm UTC](https://forum.kirupa.com/t/duplicatemovieclip-issues/34042/3 "2003-10-27T12:43:50Z")

</div>

Updated version, now totally dynamic: change the amount of boxes and watch 🙂

```auto

box._visible = 0;
spacing = {x:100, y:100};
for (i=1; i<=3; i++) {
	mc = box.duplicateMovieClip("box"+i, i);
	i%2 == 0 ? mc._x=box._x+spacing.x : mc._x=box._x;
	i%2 == 0 ? mc._y=box._y+((i/2-1)*spacing.y) : mc._y=box._y+(((i-1)/2)*spacing.y);
}

```
