So you’re an ActionScript 3 developer creating Flash games, but you can see the writing on the wall. Taking a long view, is it time to move to HTML5? If so, what’s the best approach? Here’s a way you may not have heard of, and it’s open source.
Dart has been described as Java Script, i.e., if you’re from a statically typed object-oriented background like Java, then you’ll feel right at home. Pichler doesn’t have a high opinion of JavsScript (“It sucks”) in comparison to ActionScript, so StageXL is his attempt to ease the transition from Actionscript 3 to Dart, making it as easy as possible. It’s not finished yet, but it’s already very usable and well worth a look.
How does it compare to ActionScript? Like this: DisplayObject? Check. Stage? Check. The hierarchy is all but identical. It’s like you’ve just switched to another hotel in the same chain as the one you’ve always used. It’s all so familiar, but things have moved around a little and the room layouts are a bit different.
Although the StageXL documentation needs more work, it currently includes a list of API functions and a very useful side-by-side mapping of ActionScript to Dart, more than enough to get you started.
For example, take a look at the Escape game below. (The source code is available on GitHub.) This is an existing Flash game that you can play on Funwin.co.uk. The sources and assets were provided to Pichler, and in just six hours he converted it to Dart using the StageXL library. It plays the same, though neither really stresses the processor.
By contrast a performance demo shows several hundred flags being redrawn and moving in a browser canvas at 60 frames per second. I clocked it up to 1,200 objects before the frame rate dropped to 45 fps.
It’s clear that the designer of StageXL thought it through as a way to minimize the effort needed to move from ActionScript. Although it’s not complete, the author has a roadmap of other features including video, WebGL, particle effects and more to come.