Traversing display list hierarchies in an easier means, ala-AS2? (dot syntax)
Hey all,
I've been searching around forever trying to find a way to make traversing nested display lists more of a 1-line possibility.
In AS2 you could grab a clip just by _container.clip1.nestedclip2.nestedclip3 and it was blatently simple.
In AS3, is there any way to do that?
So far my only methods are keeping a class level reference to important parts of the UI or doing a painful series of getChildByName chains until I drill down to it:
(I know the sprite casting is optional up till the last stop, but I hate DisplayObject).
var clip1:Sprite = Sprite(_container.getChildByName('clip1'));
var nestedclip2:Sprite = Sprite(clip1.getChildByName('nestedclip2'));
var nestedclip3:Sprite = Sprite(nestedclip2.getChildByName('nestedclip3'));
wtf?
I have no idea why I can't daisy chain.
var nestedclip3:Sprite = Sprite(_container.getChildByName('clip1').getChildByName('nestedclip2).getChildByName('nestedclip3'));
I know gCBN isn't a method without a cast tough and even though it's hideous, this should still work:
var nestedclip3:Sprite = Sprite(Sprite(Sprite(Sprite(_container).getChildByName('clip1')).getChildByName('nestedclip2)).getChildByName('nestedclip3')));
The casting makes the getChildByName method possible.
What's the deal on this?
