How do I correctly import swf with assets?

I’ve been trying out various tutorials from github, the documentation, topics in this forum, but none seem to fix the problem I’m having.

I have a swf file which has a movie clip in it, that I want to use. But every time I do it gives me error such as There is no asset library named "" and other similar errors.

I’ve tried doing/changing various things but I still couldn’t get the movie clip in my game.

What’s the proper way of doing this?

Are you making the SWF available using an <asset> element in your project.xml?

I think you also need to declare the SWF-reading library using a <haxelib> element.

I don’t work with SWF’s myself, but those are easy things to miss.

Did you look at official sample?

Yes, I’ve put in

I’ve looked at similar samples before (like the ones with Assets.loadLibrary() or swflite etc.) but they didn’t work too. I’ll do it again step by step, maybe you can see where it goes wrong:

I put in <haxelib name="swf" /> in project.xml, since it’s a library needed for reading swf’s

I put in the swf I need (named Grounds.swf) so now I have Assets/swf/Grounds.swf

In project.xml I put in <library path="Assets/swf/Grounds.swf" preload="true" /> right before <assets path="Assets" rename="assets" embed="false" />

I add in the movieclip in Main’s new(). There is a movieclip in the swf which, in Flash CS6 has an AS Linkage of “WoodGround” (which I assume is its name). So I put in this.addChild(Assets.getMovieClip("Grounds:WoodGround"));

And… nothing

Your Grounds.swf is in the swf subfolder, so I think you have to access it differently. Maybe in the getMovieClip() you can specify the path like so: "swf/Grounds:WoodGround"?

Nope, still nothing, and it also gave me Assets.hx:235: [openfl.Assets] There is no asset library named "swf/Grounds"

Try to build official example, if it work you have mistake in your.
Could you zip and upload somewhere your project?

The official example (SimpleSWFLayout) works. I’ve tried replicating everything from it, but still nothing appears. No errors, it’s just not showing up.

Worse case scenario I might as well just port the entire game to Flash AS3

Share your project(.zip) that I could try to build and see

Did you try moving your SWF up into the Assets folder? In case it’s indeed a directory issue

Hello. Try giving custom id for the swf file. I had similar problem and the following worked for me:

in project.xml file. To use the movieclip, i later use:


Don’t forget that you can only get items with as linkage that way and that you need to remake the swf for changes to happen.

Without a custom ID, the default ID for SWF libraries is the file name, so “rpg.swf” should be “rpg” as the ID