I can't refer to an example of an MC through a Sprite.

I thought as a Sprite is a container of display objects and I can add an instance of a MovieClip that him, I should be able to reference the MC through the Sprite.  What I've done wrong?

var bh1:Sprite = new Sprite();
beerChan = new BeerChan();
BH1. AddChild (beerChan);
trace ("bh1" + bh1);
trace (BH1.beerChan);

1119: access of property may be undefined beerChan through a reference with static type flash.display:Sprite.

Hello

If you add more things that you need to increase the number of children

BH1.getChildAt (0)

BH1, getChildAt (1)

and so on...

You can use my alternative also getChildByName ('MovieClipName')

Tags: Adobe Animate

Similar Questions

Maybe you are looking for