Hey guys,
We have launched beta versions of OpenFL on NPM, and are rapidly approaching things being stable. Some of you who have been here a while may ask, how does it work? What is it? How it different than the past releases?
NPM is the “Node Package Manager”, but really is a package manager (not unlike Haxelib) for distributing JavaScript packages. Instead of building using the same command-line tools we use for native desktop and mobile, this is a completely different toolset.
However, support for NPM (and support for Haxelib) does not require a separate codebase.
You know that Haxe compiles to many languages, and we take advantage of this to allow OpenFL (traditionally) to compile for many targets. This is all possible, so long as all of your code is written in Haxe. When we target native platforms, we do not go directly to an executable, but generate C++ and build that in another step. NPM and OpenFL is an approach that is not too different, but for the web. Instead of building an output JS file, and calling it a day, we are building to CommonJS modules (used by TypeScript, ES6, compatible with ES5 JavaScript and used in Node.js) then building a final application occurs in another step.
This means that instead of requiring Haxe to write OpenFL projects, it is now possible (albeit for HTML5 only) to use OpenFL from TypeScript, Haxe, EcmaScript 5 or EcmaScript 6 (and newer) JavaScript flavors
There are many tools that already exist for web developers, including Webpack. In our samples, we have been using Webpack and there some fun features that have come out of the box. All of our samples use the Webpack development server for testing, which includes “hot reloading.” When you make source code changes and save your file, the project recompiles, and the test browser window reloads. This even works for SWF assets now
We also going to be able to do interactive demonstrations of OpenFL more easily, as well as many other benefits from increased testing of the codebase.
We will continue to release OpenFL for Haxelib, while also producing OpenFL releases for NPM. The Lime API is currently not available on NPM, nor are the tools, but there are other little features that are nice for quickly making OpenFL content available on the web.
For example:
var sprite = new openfl.display.Sprite ();
sprite.graphics.beginFill (0xFF0000);
sprite.graphics.drawRect (0, 0, 100, 100);
var stage = new openfl.display.Stage (550, 400);
stage.addChild (sprite);
document.body.appendChild (stage.element);
You can create use the Yeoman generator for OpenFL to create new working projects:
npm install -g yo generator-openfl
mkdir NewProject
cd NewProject
yo openfl
We also have many samples available:
Please feel free to ask questions, and remember that we are still committed to existing platforms. The NPM approach is a new exciting way to use OpenFL in more projects