gafitescu
May 14th, 2005, 10:00 AM
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
var i:Number =0;
button_name.onRelease = function()
{
i++;
var instancename:String ="new_mc"+i;
var mcClip:MovieClip=createEmptyMovieClipinstancename, this.getNextHighestDepth); createRectangle(mcClip);
array.push(mcClip);
}
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 :
function createRectangle(mcClip:MovieClip)
{
mcClip.beginFill(0xFFFFF,100);
mcClip.lineStyle(1,0xFFFFF, 100);
mcClip.moveTo(parseInt(ssx.text),parseInt(ssy.text ));
mcClip.lineTo(parseInt(djx.text),parseInt(ssy.text ));
mcClip.lineTo(parseInt(djx.text),parseInt(djy.text ));
mcClip.lineTo(parseInt(ssx.text),parseInt(djy.text ));
mcClip.lineTo(parseInt(ssx.text),parseInt(ssy.text ));
mcClip.endFill();}
var i:Number =0;
button_name.onRelease = function()
{
i++;
var instancename:String ="new_mc"+i;
var mcClip:MovieClip=createEmptyMovieClipinstancename, this.getNextHighestDepth); createRectangle(mcClip);
array.push(mcClip);
}
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 :
function createRectangle(mcClip:MovieClip)
{
mcClip.beginFill(0xFFFFF,100);
mcClip.lineStyle(1,0xFFFFF, 100);
mcClip.moveTo(parseInt(ssx.text),parseInt(ssy.text ));
mcClip.lineTo(parseInt(djx.text),parseInt(ssy.text ));
mcClip.lineTo(parseInt(djx.text),parseInt(djy.text ));
mcClip.lineTo(parseInt(ssx.text),parseInt(djy.text ));
mcClip.lineTo(parseInt(ssx.text),parseInt(ssy.text ));
mcClip.endFill();}