I converted an as2 file to as3 and i am having issues with removing dynamically created children from the stage.
i am not sure how to target the mcs.
I attached the fla that has the following code on the main time line:
var left:Number = 0;
var top:Number = 0;
var right:Number = stage.stageWidth;
var bottom:Number = stage.stageHeight;
var bounce:Number = -1;
var fade:Number = 0.95;
var vx:Number;
var vy:Number;
var square_mc:square = new square();
square_mc.vx = 4;
square_mc.vy = 4;
addChild(square_mc);
stage.addEventListener(Event.ENTER_FRAME, onEnter);
function onEnter(event:Event):void
{
square_mc.x += square_mc.vx;
square_mc.y += square_mc.vy;
if(square_mc.x + square_mc.width/2 > right)
{
square_mc.x = right - square_mc.width/2;
square_mc.vx *= bounce;
}
else if(square_mc.x - square_mc.width/2 < left)
{
square_mc.x = left + square_mc.width/2;
square_mc.vx *= bounce;
}
if(square_mc.y + square_mc.height/2 > bottom)
{
square_mc.y = bottom - square_mc.height/2;
square_mc.vy *= bounce;
}
else if(square_mc.y - square_mc.height/2 < top)
{
square_mc.y = top + square_mc.height/2;
square_mc.vy *= bounce;
}
var trail:square = new square();
trail.x = square_mc.x;
trail.y = square_mc.y;
addChild(trail);
trail.addEventListener(Event.ENTER_FRAME, alphaM);
}
function alphaM(event:Event):void
{
event.target.alpha *= fade;
if(event.target.alpha < 0.1)
{
trace(“remove me?”);
}
}
Thanks in advance, as usually