OpenFL proccess swf - specify scale?


Is it possible to specify output scale for images in swf assets?
For example I have original image in fla 500x500px, but in output I would like exported images to be 250x250px (50% scale). Idealy, that images will scale automatically also, so sprites will remain the same size.

Best regards.

Can you embed the SWF content inside a container and scale the container?

var clip = Assets.getMovieClip("mySwf:MyExportedSymbolName");
var container = new Sprite();
container.scaleX = 0.5;
container.scaleY = 0.5;

The reason is to make exported images for html5 smaller during openfl proccess task

Oh interesting!

This would certainly be possible in the tools – but is not currently supported, but happy to work with anyone interested in adding features like this

Yeah, that feature would be very useful.
Previously, I was working with AS3 Flump and created this functionality:

I can try to do my best, to implement this feature, though I am new to OpenFL source. Can you mark me place, where to look and start to dance? :slight_smile:

I’m working on a new SWF format that uses a zipped single file, uses JSON instead of Haxe serialization (in order to improve backward compatibility) and which can work on Flash as well other targets

If you want to try, use type="animate" on your library and eventually I expect this will be the default. I’ve also tried to make it simpler to understand where to work on it…

The code handling the output (requires openfl rebuild tools to recompile changes) is here:

The code handling parsing at runtime is here:

1 Like

Can you please tell, where should I use flag type="animate"? In project.xml?
I do not use swf directly. For html5 I preload bundle. Do I need to process swf with some extra parameters?

I think on dev openfl process always uses the animate format, where <library /> tags do not yet, so type is for <library path="library.swf" type="animate" /> but openfl process library.swf works too :slight_smile:

Hi. I’ve managed to find some time.
So i’ve picked the develop branch and rebuilt tools.
openf process still generates binary swflite.bin.
Isn’t it implemented yet or I need to add extra parameter to process?

Ok, I found it in processFile(sourcePath:String, targetPath:String, prefix:String = null):Bool method. It is surrounded by #if false :slight_smile:

Found interesting thing:
var scripts = FrameScriptParser.convertToJS(swfData,;
Works fine for html5 target. Are there problems to support other targets?

I generally use hscript instead of it because this can be cross-platform.

Can you provide more info please?
For example I want to dispatchEvent from some frame.
Works for js. How to make it crossplatform?

@singmajesty zip library, that I created at with openfl process cannot be loaded at runtime:

Assets.loadLibrary("assets/").onComplete(lib -> {
			var mc:MovieClip = Assets.getMovieClip("swf:container");



(index):1 Uncaught SyntaxError: Unexpected token P in JSON at position 0
    at JSON.parse (<anonymous>)
    at Function.lime_utils_AssetManifest.parse (OpenflDev.js:24250)
    at Function.lime_utils_AssetManifest.fromBytes (OpenflDev.js:24220)
    at OpenflDev.js:24243
    at OpenflDev.js:12717
    at lime_app_Promise.complete (OpenflDev.js:12772)
    at OpenflDev.js:21315
    at lime_app_Promise.complete (OpenflDev.js:12772)
    at XMLHttpRequest.readyStateChange (OpenflDev.js:7490)

Also currently cannot figure out how to for example scale output image to 50% for test

Are you using the develop version of Lime as well?

The Animate library code is exported in this class:

You can search for “BitmapType.” and find the five places where images are exported. Each should have a byteArray with the output data but you could try doing something like BitmapData.fromBytes(), resize, then bitmapData.encode again. It would be inefficient but worth testing?