Undefined property in DisplayObject

Hi People,

var container:MovieClip = new MovieClip();
addChild(container);

var clip:MovieClip = new MovieClip();
clip.name = “myclip”;

container.addChild(clip);

trace(container.getChildByName(“myclip”)); //output: [object MovieClip]

trace(container.getChildByName(“myclip”).numChildren);

//output: 1119: Access of possibly undefined property numChildren through a reference with static type flash.display: DisplayObject.
can anyone explain why numchildren give me error?

i googled it, others said this error can be fix with casting, but im not sure.