I found out that I can’t target a object inside the main MC if I use getChildAt / getChildByName. It will return me
Error #1119: Access of possibly undefined property someProperty through a reference with static type flash.display:DisplayObject.
I was trying to use something like
this.getChildAt(0).getChildByName("objectName")....
getChildByNameand other get child methods return an object of typeDisplayObject. You must cast it appropriately before properties or methods not belonging to display objects. Also bear in mind that these get child methods belong toDisplayObjectContainerclass – so you cannot chain like the way you’re trying to do.Casting with
ClassName(obj)syntax will throw an error if cast fails; casting withobj as ClassNamereturns null without any errors – this might lead to confusions later as it can lead to error 1009 (null reference) at unexpected locations.