Load swf/swc assets into Haxe Flash or HTML5 targets
This post doesn’t really demonstrate anything ground breaking, never the less I figured it would be nice to write up a quick summary with working examples and lay the ground work for some future more advance posts.
So the goal is to get the assets from this .xfl asset file into both the flash and html5 runtimes.
Line 1: the first thing that you need to do is make sure that you’re OpenFL haxe project includes the “swf” haxelib library.
Line 2: Additionally you need to let your project know about the swf/swc that you intent to link.
You can effectively think of this as how you would “Add To Library” in a standard AS3 project.
A full break down of the library options for this can be viewed here.
The following code will create an instance of the Mc_Asset movieclip from the embedded swc. (This method is only available will “generate” is set to true in the library node of the application.xml file).
(Note that the following code is Haxe, not CPP.. it’s just that the wordpress code block doesn’t support Haxe).
Cool, so we have three shapes within each runtime, exciting stuff right… yeah maybe not. but having the ability to share assets across different platforms is pretty important, especially if you can pack the assets inside the highly compressed swf format.
It’s also worth mentioning that as of writing this post the html5 target only supports type=”swflite” which basically means your limited in what you can do with the swf assets. for example timeline tweens won’t work.
In the next post see how to Animate swf assets in Haxe Flash and HTML5 targets.