Extending MovieClips from an SWC with the SWF lib

Hey there everyone

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.

class MyClass extends SWCName.MovieClipName {

Is there a way to do it?

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 :slight_smile:

If you’d get a dollar for every time people wished there’d be a documentation for all these tags and tips&tricks you’d at least have 12 dollars :smile:

Aha, that sounds perfect! Thanks.
I thought it probably wouldn’t be too hard, but I didn’t know where to look.

Wuh-oh, me again!

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 :smile:

var child:Sprite = cast getChildByName ("MyChildSymbolName");

Oh gosh, I am going to need to do that one heck of a lot.

Thanks though Josh, I’ll take a stab at that later on :slight_smile:

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 :smile:

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.

Anyway, should be better :slight_smile: