开发者

AS3 Object Coercion

Hi guys I get this coercion error:

TypeError: Error #1034: Type Coerc开发者_如何学Pythonion 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?


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
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜