Step by Step procedure to convert a flash game to html5


#1

HI
I am having a flash game which i need to convert to a html5 game . Can you help me how to convert it. i tried of doing it as per instructions and commands in the blog , that output is that it is playing as a slide show but not as a game. please suggest me how to start and complete in order to get the game


#2

Which blog article are you referring to?


#3

There are two distributions of OpenFL, one for Haxelib, one for NPM.

The NPM version supports ActionScript 3.0 (using Apache Royale), TypeScript, ES5 JavaScript, ES6+ JavaScript as well as Haxe.





The Haxelib version supports Haxe only.

Both support a SWF converter for importing resources from SWF files. Neither supports using ActionScript code embedded in an existing SWF file right now.

You can check out the “demos/NyanCat” project in one of the above repositories above for an example of using a Flash animation. There’s also a “SimpleLayout” example that uses multiple resources from a SWF file by name. We support linkage names, simple animations, dynamic text and many other features (but no embedded ActionScript bytecode)

Please let me know if there’s anything more we can do to help :smiley:


#4

Hey @singmajesty and all
I am totally new in Openfl and other things, i was little bit lost about this stuff i try sample that provided example nyancat project, is the nyancat is only animation ? not full game ? if i replace nyancat.swf with other swf file is it require some manual code in main.hx ? when i replace the nyancat.swf and test it with flashdevelop it just show blank.

i try usingSWFAssets too, i already process and generate .bundle folder from swf games but i don’t know how to use it properly, i read and test it Building .bundle at runtime and i fail,
the goal i learning is i want to convert from swf flash games to html5.

Hope soon i understand what i learning
please let me know if there’'s any tutorial step by step to porting swf to html5.

Thanks.


#5

You will (ideally!) need to be able to have the original ActionScript sources for your Flash project.

Haxelib

ActionScript 3.0 can be converted using the free “as3hx” tool, or by hand, into the Haxe language. Then many of the original Flash features will continue to work in OpenFL, but the code will compile directly to C++, back to a Flash SWF, or to JavaScript. This is how most developers ship their live products for HTML5, native desktop, mobile and console platforms.

NPM

ActionScript 3.0 can be used with the Apache Royale project, to transpile to JavaScript. This also pairs with the OpenFL project to create an HTML5-only project, though I don’t know anyone who has shipped with this yet, as Apache Royale on NPM is new.

ActionScript 3.0 code could also be converted by hand to JavaScript or to TypeScript, or converted (like above) to Haxe, then linked with the OpenFL library for HTML5 deployment.

SWFs

A final Flash SWF may contain fonts, graphics, sounds and compiled ActionScript code. We currently have support for most SWF graphics in OpenFL, with ways to link it to your code. The Shumway project is the most mature solution I know to play a SWF file as-is (with no modifications), but there are some serious problems with that approach. Performance is an issue, but shipping real products often requires changes to your code.

Shumway

The Shumway project has been abandoned, but perhaps there is a fork with more promise.

Here’s a blog post from someone who tried to use Shumway recently, there may be other stories of success or failure: https://dev.to/elmuerte/shumway-shiv-scant-success-o1a

Next Steps

Going back to see if you have source code for your Flash SWF project will go a long way to helping know what your options are.

A SWF decompiler might be able to help, but converting will probably require some work, though certainly less than rewriting in JavaScript and having no Flash API library


#6

Hey @singmajesty,
Thank you for quick replay
i have fla file and some only swf files, i would like to convert games with A SWF decompiler as this is not ideal,
do you have any idea what option i have ?


#7

JPEXS looks promising since it is free/open-source, so I would probably start there. I’ve used Sothink with a license before, and there probably are some other choices out there as well. Sometimes they can convert compiled ActionScript bytecode into something legible that could be re-compiled again


#8

After using JPEXS what should i do ? should i use as3hex ?


#9

Yes, I believe you can use as3hx to convert ActionScript 3.0 code to Haxe. It does about 95%-98% of the conversion automatically, though it helps to understand some of the basics of the difference between the Haxe and ActionScript. Some of this is documented here: https://books.openfl.org/as3-conversion-guide/


#10

I’ve converting it to hx using as3hx, what next step ?


#11

Create a new OpenFL project:

openfl create project ProjectName
cd ProjectName
openfl test neko

You can drop the converted Haxe code into the “Source” directory of your new project, and can run it again.

I also recommend having Visual Studio Code and the Lime extension installed, so you have a good Haxe code editor. There are other options available, but that’s what I use :wink:

There will probably be minor compilation issues. I just helped someone on this thread with some. This older blog post may help with some issues you’ll experience, and of course, there’s the forums here and Discord for help as well.