Building .bundle at runtime

Is it possible to build a .bundle from a swf at runtime (cpp target) ?

Is <library path="to/my.swf" preload="true" /> working for you?

I mean: I would like to build a .bundle at runtime, not during compile time.

I’ve made a tool that use swf bundle, but every time we save the swf, we need to compile the bundle (that means that every person using the tool need the right version of openfl installed and do the command openfl process NyanCat.swf). I would like to make my tool able to compile the swf to a bundle.

Of course that’s not mandatory for my project. I could just ask these person to install the right version of haxe and then the tool could call haxelib to install the right version of openfl and call the process command when needed.

A way to build a .bundle from my tool/editor made with openfl would be great. Is there a way different than installing haxe and openfl? Is it possible to build the bundle at runtime ?

Sure, this would certainly be possible!

The *.bundle formats includes “library.json” inside, which can be generated outside the OpenFL tools.

If you are using OpenFL for your editor, you can import some of our classes to make this more automatic.

import lime.utils.AssetManifest;
import lime.utils.AssetType;


var manifest = new AssetManifest ();
//manifest.libraryType = "your.custom.AssetLibraryClass";
//manifest.libraryArgs = [];

manifest.assets.push ({
   id: "image.png",
   size: 1024,
   type: AssetType.IMAGE,
   path: "path/to/image.png"

File.saveContent ("path/to/library.bundle/library.json", manifest.serialize ());

If you use the default field names, lime.utils.AssetLibrary is used to load your manifest. It should support class names for assets, or paths which are preloaded with your library. Or, you can extend lime.utils.AssetLibrary with your own custom library type. This gives you full control over parsing your manifest file, or how assets are to be loaded.

I’d appreciate feedback on the whole system, but I think what you are after should certainly be possible :slight_smile:

Thanks for your answer.
So it’s possible to generate my own library.json outside the OpenFL tools. And to extract images, text and animations, I can use some code of the Tools.hx class . I’ll try soon.

Are you trying to extract content from SWF assets, or are you trying to create a custom asset library, using standard images, etc?

If you are going from SWF, is this something we would want to add to the normal SWF asset library support?


It could be great to have a way to extract content from SWF at runtime using openfl api.

I was playing with it here:

I think the main issue is moving it out of /tools so that the classes are accessible