views:

25

answers:

1

Hi guys I get this coercion error:

TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::Shape@41754601 to flash.display.

When I create an instance of a MovieClip from my library:

var childmc:ChipEasy = new ChipEasy();
Canvas.Map.Tiles.addChild(childmc);

When I try to access all the children like:

for (var i:int=0; i<Canvas.Map.Tiles.numChildren-1; i++)
{
    var mc:MovieClip = Canvas.Map.Tiles.getChildAt(i);
}

Any suggestions?

+3  A: 

One (or more) of the children is Shape, it can't be converted to MovieClip. Get children as DisplayObject, then you may check

if (child is MovieClip)
{
     var mc:MovieClip = child as MovieClip; //safe cast
}
alxx
I am such a moron! I had the remains of a shape in my empty placeholder, many thanks.
woodscreative