# Dynamic rectangle / duplicate mc / for statement

**URL:** <https://forum.kirupa.com/t/dynamic-rectangle-duplicate-mc-for-statement/224348>\
**Category:** Uncategorized\
**Created:** [May 1, 2007, 5:32pm UTC](https://forum.kirupa.com/t/dynamic-rectangle-duplicate-mc-for-statement/224348 "2007-05-01T17:32:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tsj4](https://avatars.discourse-cdn.com/v4/letter/t/7ea924/32.png) [@tsj4](https://forum.kirupa.com/u/tsj4)\
**Post date:** [May 1, 2007, 5:32pm UTC](https://forum.kirupa.com/t/dynamic-rectangle-duplicate-mc-for-statement/224348/1 "2007-05-01T17:32:53Z")

</div>

I am trying to create a styled mc dynamically which works great that I will then duplicate and populate with xml data. Issue is I am able to create the container clip with script but when I try to duplicate it in a for statement nothing appears on the stage not even the first rectangle named container.

Here is the code

```auto
 /////////////////////////////
// -- Rectangle Function
/////////////////////////////
function drawRectangle(mcClip:MovieClip, nWidth:Number, nHeight:Number):Void {
    mcClip.lineTo(nWidth, 0);
    mcClip.lineTo(nWidth, nHeight);
    mcClip.lineTo(0, nHeight);
    mcClip.lineTo(0, 0);
}
/////////////////////////////
// -- Draw Rectangle
/////////////////////////////
var container:MovieClip = this.createEmptyMovieClip("container", this.getNextHighestDepth());
_root.container.lineStyle(1, 0x000000, 0);
_root.container.beginFill(0x332211, 50);
drawRectangle(container, 60, 60);
_root.container.endFill();
/////////////////////////////
// -- Variables
/////////////////////////////
var xPos = 60;
var yPos = 60;
/////////////////////////////
// -- Create Thumb
/////////////////////////////
for (i=0; i<10; i++) {
    _root.container.duplicateMovieClip("new"+i, i, {_x:xPos, _y:yPos});
    xPos += _root["new"+i]._width+5;
    if (xPos>400) {
        xPos = 60;
        yPos += 60;
    }
} 

```
