vendredi 31 mars 2017

AS3: How to access children of children of children?

Is there a better (quicker, shorter or neater) way to access a child sprite (object) 3 layers or more deep? If the children have all been given names and you know the names. Is there a better way to do it than the code I made below?

var mySprite:DisplayObjectContainer = layerASprite.getChildByName("layerA") as DisplayObjectContainer;

mySprite = mySprite.getChildByName("layerB") as DisplayObjectContainer;

mySprite.getChildByName("layerC").y = 200;

Aucun commentaire:

Enregistrer un commentaire