Flash to Phaser JSFL Script


What is it?

Flash to Phaser is a JSFL script that will aid in the process of laying out scenes within the Flash IDE and converting them into Phaser JavaScript files. It works by parsing the Stage for any Bitmap or Symbol objects and then automatically builds-up a JavaScript source file including preload and create functions that accurately re-create what is seen inside the Flash IDE.

If the script encounters a Symbol it treats it as a Phaser Group and uses the Symbol name as a Group name. Any Bitmaps within the Symbol are treated as Group children and positioned accordingly.

Objects have their x, y, rotation and scale properties re-created in the JavaScript.


Download the JSFL file from Github (you’ll also find this guide as a PDF there)

There are two ways to install JSFL scripts into the Flash IDE. One is to copy them into the Flash application data folder, specifically into the “Configuration/Commands” sub-folder. The location of this varies tremendously based on OS and Flash version. There is a slightly out dated guide available here on the Adobe site.

An easier method is to create the script manually, which is what I’ll describe here.

1) Open Flash. In this guide I’m using Flash CC, but the process should be the same regardless.

2) On the “Open” screen select “Create New: Flash JavaScript File”


3) The Flash IDE will open a completely blank document. Copy and paste the entire contents of the “Flash to Phaser.jsfl” script into this editor window. You can find the latest version of this script in the Phaser github repository in the ‘resources’ folder.


4) Once pasted in, select “File – Save As” and it will prompt you for a name for the script. Enter “Flash to Phaser.jsfl” and hit “Save”.

5) The script is now installed and ready for use.

How to prepare your FLA

The JSFL script works by parsing all objects that are on the first Layer of the Stage. It only supports Bitmaps and Symbols.

It will automatically round object x/y values to the nearest whole pixel. If you don’t wish for this you can edit the JSFL script and set the var round Boolean to false.


These are the easiest to manage. Simply drag all the images you require for your game into the Flash Library. Then drag them onto the Stage ensuring they are on the first Layer. Once on the Stage you can position them, rotate them and scale them as required.

The order in which they are layered on the Stage controls the order in which they are created within Phaser. So bitmaps placed “behind” other bitmaps will re-create in that order in the generated JavaScript code.


The script converts Symbols into Phaser Groups. A Symbol can contain as many Bitmap objects as you like, all positioned, scaled and rotated as required relative to the parent.

When the script runs it will identify that you’ve got a Symbol on the Stage and generate a Phaser Group based on its name. The Group will be positioned matching the Symbol coordinates.

It will then scan one level deep within the Symbol for any Bitmap objects and create those as children of the Group. There are two important things to remember to ensure an accurate export:

  1. The Symbol name becomes the Group name, with any spaces removed.
  2. The Symbol registration point must be the top-left:


In the screen shot below you can see several bitmaps dragged onto the Stage:


The rotation of the bunny sprite, the scale of the computer will all be exported. The flying hotdogs are part of a Symbol and will be exported as children of them. Here is the resulting JavaScript code:


You can see how the script has worked out which images to preload, assigned them all safe keys and created unique local variables for further editing.

How to run the JSFL Script

Once installed you can select the script from the “Commands” menu within Flash. It will appear on the list as “Flash to Phaser”:


The script will run immediately upon selection, so make sure your FLA is prepared and saved before launching it.

When the script has finished running a “Save As” window will appear:


This is asking for the name of the JavaScript file that will be saved. Give it a name and if all has gone to plan a new JS file will be saved into the location specified. You can also see the content of the JavaScript file in the Flash “output” window.

Comments and Enhancements

Hopefully you’ll find this script useful. Feel free to enhance or modify it to best suit your needs. If you add a particularly useful feature please submit a Github Pull Request so we can merge those changes back into the library for everyone else to benefit from.

This script is provided as-is under the MIT License. No technical support is provided. Although if you do get stuck, please ask on the Phaser Forum.

Posted on May 28th 2014 at 3:35 am by .
View more posts in Phaser. Follow responses via the RSS 2.0 feed.

5 Responses

Leave a comment
  • shanadeshana
    May 28th 2014 at 2:37 pm

    Thanks for this!! I found a way to use inkscape as a level editor but this is a lot better. Do you know if is possible to use this with texture atlases? Game loading time is very important when working with sponsors.

  • May 28th 2014 at 2:48 pm

    It won’t work with texture atlases, it’s more for object placement and setting-up a game scene or level, not a replacement for asset creation I’m afraid. Even so, once you’ve got your atlas made you can use this to position it into the scene.

  • May 29th 2014 at 12:25 pm

    This is HUUUUGE guys!!!

  • Ryan
    May 30th 2014 at 6:27 am

    Look good.
    Does it create sprite sheets for animations?

  • Alex
    June 5th 2014 at 1:40 pm

    Funnily I’ve just been tinkering with an equivalent jsfl script of my own. What was the thinking behind the idea of limiting it to only handle the first layer? It’s simple enough to iterate over each of the layers in the array with only a couple of extra lines of code.

Make yourself heard