Flash AS3 to Haxe/OpenFL

Hi OpenFL community, I’m a flash AS3 dev moving to greater heights of OpenFL, I’m new to Haxe/OpenFL can you guys recommend me some good tutorials on moving from AS3 to Haxe/OpenFL and a “how to setup Haxe/Openfl” so i can start with trace(“Hello World”), Thanks!

1 Like

This tool will help you convert your code, but it isn’t perfect. You’ll still have to do about 10% of the conversion by hand.

Here is a tutorial for installing Haxe and OpenFL. If you already have them installed, you can skip to this tutorial instead.

Thanks! and woah! it’s player_03! we miss you on Kong Dev Forums, I’m a fan of your games RUN 1,2,3 on Kongregate.

1 Like

I found the migration to Haxe/OpenFL fairly painless. For the most part, you can code like you would for the native Flash API, just with a few considerations.

Typing is stricter. ActionScript allows for a fair bit of leniency when passing one object type into another, for example a Number into an int. In Haxe, you need to explicitly convert one type to another.

More consistent syntax. Some object types in ActionScript are all lowercase, such as void, int, uint, which is inconsistent with most object types. All types in Haxe are capitalized.

For loops are quite different.

Some shorthand doesn’t work, such as if (!someValue). You need to write the full if (someValue == null).

There are no constants, but there are inline values which work a little differently and can be useful tool for optimizing code. Anything referencing an inline variable, will literally have that value when compiled, as though it wasn’t referencing a variable at all.

Here’s a useful comparison:

A couple other important differences that impact my work in particular, is that there is currently no universal webcam support, or video playback. I have seen a few folk in the forums working on the video playback at least.

1 Like

Thanks for the info, is there any available documentation or tutorial on how to import flash assets to OpenFL?

I can’t quite get why is the for(var) became

from this:
for (var i:uint = 0; i < 100; i++) {


to this:
for (i in 0…100) {


are the 3 dots mean greater than or less than?

@TheRuss16 less than.

1 Like

Using SWF Assets

Or for more general assets:
Assets in OpenFL: embedding images, sounds and more

1 Like

This is because Haxe for loops work as iterators

In Flash, consider for (child in children). In Haxe, all loops work this way.

The 0...100 shorthand creates an iterator that goes from 0 to 100. The Haxe default number iterator only supports increasing, not decreasing, values.

This approach is nice most of the time

1 Like