Can I download and use SWFs at runtime?

my memory could be faulty: is it possible to download (and parse) SWF files at runtime like the other assets, avoiding to explode them at compile time?

Yes, you can load a SWF the same way you would load a Bitmap.

var loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onSwfLoad);


function onSwfLoad(e:Event):Void {

More info here: Load External Swf Library

1 Like

Yes, you can currently do this, only if you openfl process your.swf first. Then you can use AssetLibrary.loadFromFile () with the path to the .bundle or you can use Loader and load the .bundle path. Something like:

openfl process your.swf swf.bundle

Generates “swf.bundle” (last argument is an optional output path)

AssetLibrary.loadFromFile ("path/to/swf.bundle").onComplete (function (library) {
    var clip = library.getMovieClip ("");
    addChild (clip);
}).onError (function (e) {
    trace (e);


var loader = new Loader ();
loader.contentLoaderInfo.addEventListener (Event.COMPLETE, function (event) {
    var clip = loader.content;
    addChild (clip);
loader.contentLoaderInfo.addEventListener (IOErrorEvent.IO_ERROR, function (event) {
    trace (event.text);
loader.load (new URLRequest ("path/to/swf.bundle");
1 Like

Any update about the SWF import? I still need to download an SWF containing a lot of images and animations in my HTML5 app, avoiding to download hundreds of small files.
Is it possible to combine bundle and pak features to preprocess/explode the SWF, integrating the classes in the app and repacking the assets (images + json) in a single .pak? Ideally the best solution would be 1x app.JS + 1x embedded assets.pak + Nx remote assets, where assets.pak contains all spritesheets, sounds and swf resources.

I have extended the SWFLite load library, but this requires changing how it is loaded.

1 Like

Great! I will take a look and try to understand how to use it :wink: