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;}