# Problem with multiple, dynamically drawn buttons \[renamed\]

**URL:** <https://forum.kirupa.com/t/problem-with-multiple-dynamically-drawn-buttons-renamed/147853>\
**Category:** Uncategorized\
**Created:** [May 14, 2005, 2:00pm UTC](https://forum.kirupa.com/t/problem-with-multiple-dynamically-drawn-buttons-renamed/147853 "2005-05-14T14:00:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gafitescu](https://avatars.discourse-cdn.com/v4/letter/g/8e7dd6/32.png) [@gafitescu](https://forum.kirupa.com/u/gafitescu)\
**Post date:** [May 14, 2005, 2:00pm UTC](https://forum.kirupa.com/t/problem-with-multiple-dynamically-drawn-buttons-renamed/147853/1 "2005-05-14T14:00:56Z")

</div>

I had to create dynamic with AS some rectangulars on stage using moveTO and lineTo.I had a button and when I press it should add a new rectangle on stage but it doesn’t.Because the array that I am storing the mcClip created are overriding I guess

**[color=#993300]var[/color] i:[color=#000087]Number[/color] =0;**  
**button\_name.[color=#000087]onRelease[/color] = [color=#993300]function/color**  
\*\*{ \*\*  
**i++;**  
\*\*[color=#993300]var[/color] instancename:[color=#000087]String[/color] =[color=#0000ff]“new\_mc”[/color]+i; \*\*  
**[color=#993300]var[/color] mcClip:[color=#000087]MovieClip[/color]=[color=#000087]createEmptyMovieClip[/color]instancename,[color=#000087]this[/color].[color=#000087]getNextHighestDepth[/color]); createRectangle(mcClip);**  
\*\*array.[color=#000087]push/color; \*\*  
**}**

After adding some rectangles the array look lile this  
,\_level0.new\_mc2 …but the first and the second movieClip dissapers and on stage it’s the last one created.

How do I solve this problem?

This is the createRectangle function if you are interested :

**[color=#993300]function[/color] createRectangle(mcClip:[color=#000087]MovieClip[/color])**  
**{**  
\*\*mcClip.[color=#000087]beginFill/color; \*\*  
**mcClip.[color=#000087]lineStyle[/color](1,0xFFFFF, 100);**  
**mcClip.[color=#000087]moveTo/color;**

**mcClip.[color=#000087]lineTo/color;**  
**mcClip.[color=#000087]lineTo/color;**  
**mcClip.[color=#000087]lineTo/color;**  
\*\*mcClip.[color=#000087]lineTo/color; \*\*  
**mcClip.[color=#000087]endFill/color;}**
