ActionScript 3.0 Support

OpenFL 8.1 is here, and introduces beta support for ActionScript 3.0 as a source language!

We’d love additional feedback on how we can improve the workflow in our samples.

To get started, enter any of the samples, run npm install then npm start.

We expect to continue to work with Apache Royale until we can bring the workflow up to par with our other supported source languages on NPM (Haxe, TypeScript, ES5 JavaScript, ES6 JavaScript).

Thanks for your support, feedback and help!

OpenFL 8.1 is available on both NPM and Haxelib. Though this is primarily an NPM feature-based release, there are some minor fixes for the Haxelib release as well :grin:

4 Likes

Good!But how to use openfl test html5 way to test?

I know how to test it, but I’m not quite sure how to use npm to generate an apk?

Great! Is it only for flash, html5 and Air target? Or is it possible to target also windows, linux, neko…?

It uses NPM currently, but ActionScript sources could also use Adobe AIR to generate an APK, the same way you would normally.

This is not currently using the openfl tools, so npm install then npm start -s is the way to test one of these samples

If you want to target HTML5, then we support Haxe, JavaScript, TypeScript and (now) ActionScript 3.0 as input languages. This uses NPM for linking tools together.

If you want to target Flash or Adobe AIR targets (Android, iOS, Windows, macOS) then there already are Adobe-based workflows for using ActionScript 3.0.

It’s also worth mentioning you can use HTML5 + Electron to build desktop applications using all of the above languages.

Lastly, if you want to target HTML5, Flash, AIR, Android, iOS, Windows, macOS, Linux, WebAssembly, consoles and other targets using the OpenFL tools, Haxe is the only supported language today.

Can I use starling on npm? Haxe original library can support it?

We just released [email protected] on NPM, which supports ActionScript 3.0, now!

You can check it out by doing the following (assuming you have NPM and Java installed):

git clone https://github.com/openfl/starling
cd starling/samples/demo_npm/as3
npm install
npm start -s

If you’re using Visual Studio Code, you should be able to open that “as3” folder and be able to use the “ActionScript & MXML” extension for a better development experience

The “cpx assets/**/. bin/js-debug/assets” command looks like an anomaly. Remove the build dev, but not the assets.

"scripts": {
    "build": "npm run build:dev",
    "build:dev": "cpx 'assets/**/*.*' bin/js-debug/assets && cpx node_modules/openfl/dist/openfl.min.js bin/js-debug && cpx node_modules/howler/dist/howler.min.js bin/js-debug && cpx node_modules/starling-framework/dist/starling.min.js bin/js-debug && cpx node_modules/pako/dist/pako.min.js bin/js-debug && asconfigc --debug=true",
    "build:prod": "cpx 'assets/**/*.*' bin/js-release/assets && cpx node_modules/openfl/dist/openfl.min.js bin/js-release && cpx node_modules/howler/dist/howler.min.js bin/js-release && cpx node_modules/starling-framework/dist/starling.min.js bin/js-release && cpx node_modules/pako/dist/pako.min.js bin/js-debug && asconfigc --debug=false",
    "start": "npm run start:dev",
    "start:dev": "npm run build:dev && royale serve:debug",
    "start:prod": "npm run build:prod && royale serve:release"
  }

After the reference command, “cpx ‘assets/**/.’ bin/js-debug/assets” is required to work properly.

[Error] TypeError: undefined is not an object (evaluating 'b.prototype')
	v (Main.js:4:246)
	全局代码 (Main.js:6:986)
[Error] ReferenceError: Can't find variable: Main
	全局代码 (localhost:40)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (starling.min.js.map, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (openfl.min.js.map, line 0)

When using Release to release the official version, the above exception will be reported.

Does the dev build work?

Yes, the dev build can work

Okay, so one approach might be stage.addChild (new Main ()) instead of passing by reference. There is still more work to do here to integrate more fully with Closure Library, which Royale uses

So … Josh … think I could get Scarygirl running this way :stuck_out_tongue:

1 Like

Haha. And we switched to Haxe 10 months ago :smiley:

So what are the pros and cons of using AS3 or Haxe with OpenFL?

The Haxe to JavaScript support is more solid, currently. Easier to use external code, better code output, but Apache Royale is promising. I’m working on sending issues their way as we go, so we can try to help improve the quality. I had issues using Vector.<T> due to circular dependencies, but I think a different JavaScript “emitter” for them would fix it – maybe there’s a better solution.

The compiler is written in Java, and it’s pluggable to write new language “emitters”, if someone moved their JS from Closure to, say, ES6 modules, I think that would make it a lot more useful. I also think if someone wanted, writing a Haxe emitter could (maybe) be the best AS3 -> Haxe converter ever.

The obvious difference Haxe and ActionScript (all things being the same) is Haxe’s additional features and more platform targets :slight_smile:

1 Like

This is interesting – https://github.com/damoebius/HaxeBench

I wonder how AS3 would compare here

I like the JS export format of Openfl-NPM (AS3) very much, because it can be divided into JS files. I don’t know if Openfl-Haxe supports this. If I use Openfl-NPM (Haxe), should it be divided into multiple JS files? Maybe I can try it.

There’s a way to use hxgenjs to separate your output into CommonJS or (optionally) ES6 modules, though a single JS file is usually good for final output