Confusion regarding ActionScript conversion to HTML5 via OpenFL / Haxe


#1

@singmajesty

Hi

I am a total beginner and have just started learning OpenFL.
I have to convert Flash Games (with ActionScript 3.0) to HTML 5 via OpenFL.

I just came across the as3hx conversion library for the conversion part.

My confusion is after converting ActionScript to Haxe code, do I have to make the modifications using Haxe code or OpenFL code. Can we not make use of one language for modifications (Haxe or OpenFL) post the conversion process.

Please clear my doubt as why do we need both (Haxe code and OpenFL) languages ??
Is either one of these languages not enough ?

Sorry for asking this basic question but I am a total newbie …Thanks


#2

Hi kiranzz,

I was pretty much in your situation 3-4 months ago :slight_smile:

Haxe is the language and compiler, openFL is a framework/library that reproduces flash API and relies on Haxe

You write code for openFL using Haxe language. What openFL provides is all the classes you know from Flash (Stage, Stage3D, MovieClip, BitmapData, Sound etc).

as3hx conversion does not assume you will use openFL or another framework : it converts as3 code to haxe code. It will keep flash-specific stuff as flash stuff : MovieClips are still flash.display.MovieClip

This is a part that is a bit blurry for me : the whole flash API is available in Haxe, if I’m not mistaken it’s what gets called “extern classes”. If I understand correctly it’s up to the framework you’re using to bind the flash classes to relevant classes when you export.

So if you use openFL, when exporting to html5 a flash.display.MovieClip class will become an openfl.display.MovieClip class. You don’t need to worry about this, it’s automatic. If you want you can go through your code and change any “flash.x.y” import with “openfl.x.y” but I’m almost sure you don’t need to do this.

Basically once you have converted your as3 code using as3hx what you need to do is decide on which IDE you want to use (I use HaxeDevelop on windows - a fork from FlashDevelop - it works pretty well), create an OpenFL project and copy your code and assets to it.

Then edit the project.xml file at the root of the project to fit your needs, using this link as reference : http://www.openfl.org/lime/docs/project-files/xml-format/

Hope this helps a bit


#3

Hi!

Just a few things to add to @Matse’s good answer :slight_smile:

An “extern class” means something that will be available at runtime. A Flash SWF will have flash.display.Sprite available within Flash Player or Adobe AIR.

However, not all runtimes are alike. AIR has additional classes built into it that are not available in the Flash Player plugin. Similarly, when targeting the web browser, certain things (such as CanvasElement) are available – built into the browser.

Outside of Flash, OpenFL has a compatible implementation as openfl.display.Sprite, and we have a little thing that can rename a flash.* into an openfl.* import. Using openfl.* can result in slightly better behavior, but both can work.

The IDE I use is Visual Studio Code, using the “Lime Extension”. It doesn’t use project files, open the root directory of an OpenFL project and it will enable support for code completion and for adding compile targets. FlashDevelop is also a great IDE on Windows.

Step 1 is using OpenFL with your code to compile to Flash. This helps you make sure that you’ve successfully transferred from ActionScript to Haxe code.

Step 2 is using OpenFL with your code to compile to HTML5 (and other platforms). Once you have a project compiling to Flash, it’s usually close to working on other platforms


#4

Thanks @Matse and @singmajesty