Porting finished Flash game to OpenFL?

Hello. Sorry if this is a stupidly basic question, but I’ve been searching a bit and I’ve not found a simple solution yet.

I’ve been making Flash games alone for over a decade now, though I’ve never really been involved in the community/scene so I’m in the dark about a lot of things.

I just spent several months making a rather in-depth RPG in Flash (I’m not here to advertise it, but here’s a trailer to give an idea of what I’m talking about), but while reading about how best to release and make money from it, I got the general impression that ‘Flash is dead!’ and basically panicked about that! Especially since this game of mine is intended to be released in episodes over the course of several years, using the same engine and assets.

I’ve been developing it in Flash CC using ActionScript 3, and the code and Flash animations already exist. I’m unsure whether it’s even possible to port it to mobile devices and such though, with what I already have.

I came across OpenFL while doing research about what I should be using instead, but I’m not sure what I actually need to do. Is it possible to use the existing code and animations and so on, or will I have to edit or even rewrite a lot of stuff? If I’ve already been using Flash CC and everything’s finished, do I need to be using OpenFL at all?

1 Like

Welcome here,

Yes there will be some work, since openfl is haxe and not as3, but most of the work can be done by scripts.

What you need to do is convert your as3 code into haxe, first launch https://github.com/HaxeFoundation/as3hx and then manually clean the, hopefully few, remaining errors.

You’ll be able to use your animations with this https://github.com/openfl/swf/

You can find openfl samples here https://github.com/openfl/openfl-samples
they should give you a better idea on the structure of an openfl project.

PS: your game looks good

1 Like

Thanks for the links! It definitely gives me somewhere to start.

I’m currently looking at the samples (which were already installed when I installed OpenFL, apparently), and I prefer that structure to having everything in a .fla file, but I don’t know how to compile them into a playable game.

I tried the command “openfl create PiratePig”, for example, but nothing seemed to happen. The documentation says it’ll create “a copy of the sample within the current directory”, but I’m unsure what that means. What is the ‘current directory’ (the OpenFL directory? The PiratePig one? Some command line specified thing I don’t understand?), and what is a ‘copy’? I was expecting it to create a playable exe or something, but I didn’t notice any new files appearing in the PiratePig directory.

I haven’t used a command line in years, so this is probably going to take some getting used to!

Oh, wait, I just found this page: http://www.openfl.org/documentation/command-line-tools/basic-commands/

I think that might explain what I need to do, so I’ll read that and see what I can figure out.

To compile the game and run it on windows execute the following command from the project directory:

openfl test windows

To get a description of all available commands execute the following:

openfl help

Okay, I’m making progress, having to teach myself how to use a command prompt and downloading a bunch of things from different places just to get anything working… though I’m confused about the as3hx thing. I have no idea how to use it! The documentation simply says:


You’ll need Haxe 3.* to build the project and Neko 2.* to run it.


But I don’t know where I’m expected to type that. I cd’d my way to the directory where as3hx is saved, but simply typing ‘make’ just gave an unrecognised command error.

‘make’ is but one of a suite of c/c++ command-line tools. Its native to linux and osx but you’ll have to install it for windows.

Here’s are a few resources:

Or do haxe --no-traces as3hx.hxml manually (it’s the only thing make do here).

1 Like

Does all the documentation just assume everyone using this is a hardcore programmer using Linux or something? Maybe I’m the only one who’s not both of those things, though!

Anyway, haxe --no-traces as3hx.hxml created the run.n file properly… so for now I won’t bother trying to install that other thing (though thanks for the links, in case I need it later).

But now when I try and actually run as3hx according to the terse documentation, I’m getting this:

Called from ? line 1
Called from Run.hx line 102
Called from Run.hx line 33
Called from C:\HaxeToolkit\haxe\std/neko/_std/sys/FileSystem.hx line 85
Uncaught exception - std@sys_read_dir

No haxe files are produced.

Sadly yeah a lot of documentation (well a lot in the few documentation we have) isn’t beginner friendly :confused:

Looks like there’s a problem while reading your source directory, just to be sure the run.n file works could do a neko run.n -help?

Does your source directory have spaces in it, or special non ascii characters?

1 Like

Typing neko run.n -help does work; it lists a bunch of options.

The directory I was using was titled m3, and it had two folders inside: as3 and hx. So I was trying

neko run.n m3/as3/ m3/hx/

That didn’t work. Nor did omitting the output directory (neko run.n m3/), not using nested folders (neko run.n m3/ out/), omitting the slashes at the end (neko run.n m3 out)…

What if you do haxelib install as3hx then haxelib run as3hx path/to/source path/to/output?

1 Like

That worked perfectly! Thank you! Odd that it’s not mentioned anywhere in the documentation though.

Sorry for the late reply; I just noticed this thread.

As much as I love OpenFL and would recommend it to anyone… No, you don’t need to be using it.

An easier alternative would be to compile to AIR, which as I understand it is like Flash Player except that it runs on more platforms. It interprets AS3 bytecode, so you won’t have to rewrite your whole app, and it creates native iOS and Android apps, so you can submit your app directly to the App Store and Google Play.

The downside is that AIR is an interpreter. You’d get better performance using OpenFL. (That said, Flash Player is also an interpreter, so if it works fine in Flash, it should work about as well on mobile.)

Another downside, at least if you’re worried about decompilers, is that it may be hard to obfuscate your AIR apps. I’m pretty sure each app would contain a SWF file that you could run through SecureSWF or whatever. However, to get at this file, you’d have to take apart the Android or iOS app, and putting it back together afterwards would not be an easy task.

OpenFL doesn’t obfuscate your code, but it compiles to C++, which is equally good.

Not all the documentation, but I find that many Linux users assume that “make” works for everyone, even though Windows users have to jump through a bunch of hoops.

Besides that, the command line isn’t that bad. There are a few tricks that will make your life easier, but for the most part all you have to do is follow instructions.