So I am using this code to embed my .swf file. I am creating classes for each asset in my library.
[Embed('assets/assets.swf', symbol='game.menu.levels')]
public static const LEVELS_MENU:Class;
It works just fine but how can I access a child element multiple depths down?
I have this thus far:
this.object = new R.LEVELS_MENU();
var child_element:MovieClip =
this.object.getChildByName("child_element") as MovieClip;
Is there a better way than doing this:
var child_child_element:DisplayObjectContainer =
DisplayObjectContainer(
child_element.getChildByName("child_child_element")
);
var child_child_child_element:DisplayObjectContainer =
DisplayObjectContainer(
child_child_element.getChildByName("child_child_child_element")
);
Is there a way I could do it with dot syntax as such:
child_element.child_child_element.child_child_child_element...
Not as far as I am aware.
There might be a workaround.
If you created those children from the Flash IDE, you should be able to access them directly via references like this:
Or if you are doing that MovieClip initialization manually (new operator) inside the swf, you can also create those references manually like this:
Though this won’t matter for movieclips, as they are dynamic, so you can just do:
These last two are inside .swf code of course;