The supplied DisplayObject must be a child of the caller plz help!
Hi hope someone can help me with this.
Im adding child to a MovieClip bg
----------------------------------------------
for (var i:int =1; i<=cols; i++)
{
for (var q:int = 1; q<=rows; q++)
{
var random_card = Math.floor(Math.random() * colordeck.length);
tile = new colors();
tile.width = widthvar;
tile.height = widthvar;
tile.col = colordeck[random_card];
colordeck.splice(random_card,1);
tile.gotoAndStop(9);
tile.x =(i+.2)*xvar;
tile.y = (q+adjust)*yvar;
tile.addEventListener(MouseEvent.CLICK,tile_clicked);
bg.addChild(tile);
}
}
------------------------------------------
When I removeChild(bg) it doesnt remove its children and ones I addChild(bg) again
it adds more children on top.
How can i remove these from bg?
I tried:
----------------------------------------
if (bg.contains(tile))
{
for (var i:int =1; i<=cols; i++)
{
for (var q:int = 1; q<=rows; q++)
{
bg.removeChild(tile);
}
}
}
---------------------------------
but get an error:
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
if you can help id rly appriciate it
thx pavel
