Actionscript Removing Display Objects

Posted by Chunk1978 on Stack Overflow See other posts from Stack Overflow or by Chunk1978
Published on 2010-03-19T20:47:43Z Indexed on 2010/03/19 20:51 UTC
Read the original article Hit count: 189

Filed under:

i don't understand why none of my display objects are not being removed. when i press the button, i'm expecting a trace and removal of both shapes and the button, but nothing happens:

import fl.controls.Button;

var shape1:Shape = new Shape();
shape1.name = "Shape1";
shape1.graphics.lineStyle(4, 0x000000);
shape1.graphics.beginFill(0x000055, 0.5);
shape1.graphics.drawRoundRect(50, 50, 100, 75, 20, 30);
shape1.graphics.endFill();
addChild(shape1);

var shape2:Shape = new Shape();
shape2.name = "Shape2";
shape2.graphics.lineStyle(4, 0xFFFF99);
shape2.graphics.beginFill(0x550000, 0.5);
shape2.graphics.drawRoundRect(100, 75, 200, 175, 50, 10);
shape2.graphics.endFill();
addChild(shape2);

button1.addEventListener(MouseEvent.CLICK, pushButton);
function pushButton(evt:MouseEvent):void
    {
    for(var amount:int = numChildren; amount == 0; amount--)
        {
        trace(amount);
        var disObj:DisplayObject = getChildAt(amount);
        trace("Removing " + disObj.name);
        removeChildAt(amount);
        }
    }

© Stack Overflow or respective owner

Related posts about actionscript-3