I’ve been playing with the SWF lib today, trying to figure out how difficult it’ll be to port one of our AS3 games over to native targets using it and the as3hx lib.
One thing I couldn’t figure out how to do though, was extend MovieClips that are in the SWCs I’m using.
I want to do something like this, just as an example.
Try using something like <library path="to/your.swf" generate="true" />, this generates Haxe classes to match each “Export for ActionScript” symbol in the SWF
Is there a way to access child symbols by their instance names? I’ve been fighting through errors all day now, and mostly it’s gone ok, but now I can’t seem to access any of the buttons (for example) in my MovieClips and can’t think of a smart way around it.
We used this sort of thing a lot in our AS3 games, usually with several layers of nesting.
At the moment, the child objects are not defined in the generated classes. I was thinking this would be helpful to prevent extra bootstrapping, although it still would not apply to children of children unless we made all the classes Dynamic. Perhaps that would be fine for JavaScript, but in C++ it could really reduce the performance.
Try this one
var child:Sprite = cast getChildByName ("MyChildSymbolName");
I just added generation for named child instances.
So instead of var child:Sprite = cast getChildByName ("MyChildSymbolName"); simply MyChildSymbolName should be defined and appear in code completion
Since I am not populating dynamic properties on SWF MovieClip instances, getChildByName is still required for the second level. I am debating whether to do dynamic anyway (even though its slower), to make it an option, or to leave this as-is.