I’m trying to use SWF assets following the @singmajesty tutorial…
…but I can’t get it to work.
I get the error:
Error: Could not find haxelib “swf”, does it need to be installed?
I’m using Atom, but, haven’t had (too m)any issues with it (and have successfully built to several targets).
Any idea what I’m doing wrong?
(I’m using OpenFL 4.5.2 and lime 3.5.2)
Try it without
<haxelib name="swf" /> in the project.xml, and see if that works. We recently merged SWF support into OpenFL (core) and have made improvements to deeply integrate it
A question about this feature: we can use swf mainly for graphic libraries, right? Do movieclips work? Code found on swf is ignored, right?
I believe that MovieClips should work, but you cannot use code added to the timeline.
However, you can use the undocumented
movieClip.addFrameScript function (which mind you, has a zero-based index) to attach Haxe scripts to frames on a
Ok, so I re-used the simpleSWFLayout, and got a swf to load.
I can’t load my SWF (even though all code has been removed), but if I drop my MCs into the layout.fla and republish, I can load them.
So, does it have to be called “layout” or, is their something exceptionally obvious that I’ve missed?
And does this swf import and addFrameScript work on all targets?
Not sure, I’m only using SWF for testing and HTML5 for the actual output. I tried Mac app, and it appeared to work (despite throwing an error);
Didn’t try addFrameScript
There are three ways to get SWF content into your project. Let’s say you use the following in your project file:
<library path="library.swf" generate="true" preload="true" />
The ID will be called “library” by default (though you could add
id="puppy", etc, to change this name)
You can now load the whole timeline, or a symbol that was marked as “Export for ActionScript” in Flash Professional / Adobe Animate.
var timeline = Assets.getMovieClip ("library:");
var clip = Assets.getMovieClip ("library:MyExportedSymbolName");
If you use
generate="true", classes are generated for your “Export for ActionScript” symbols, letting you instantiate them directly, similar to what you would use in ActionScript:
var clip = new MyExportedSymbolName ();
You can add
prefix="SWF" (or some other prefix) if the exported names will conflict with other classes you have in your project. With the latest OpenFL, you should also be able to use custom base classes in your SWF, and have it link up for you, similar to ActionScript
All of that works, the only thing that doesn’t is my FLA/SWF - if I copy an MC over, it’s fine - I expect the FLA is corrupted.