Changing the Flash API (We Have the Technology)

I came across a devious discovery.

I found that I can change the Flash API.

Conditional compilation and typedefs are two features which are available in Haxe, but not in Actionscript 3. NME uses these features to alias “nme.display.Sprite” and other classes to “flash.display.Sprite” and our backend classes for the native and browser targets.

This is powerful for implementing a unified API across multiple platforms, but because we do not control Flash Player, we have not been able to fiddle with the definition of “flash.display.Sprite” … until now. Continue reading Changing the Flash API (We Have the Technology)

How to Install the Standalone Flash Player on Linux

If you are interested in testing a Flash application while you are running Linux, you will want to install a standalone version of Flash Player.

Unfortunately, installing the Flash Player Debugger and associating it with your SWF files can be tough to figure out, so I have written a script that will download, extract and associate the standalone Flash Player for you :) Continue reading How to Install the Standalone Flash Player on Linux

Getting Started with Haxe/Flash in MonoDevelop

If you have not installed Haxe and MonoDevelop yet, go to this post to read the easy instructions.

You can make a new Haxe/Flash project in MonoDevelop by going to File > New > Solution from the menu.

Now that we have a new project, let’s try drawing a shape:

graphics.beginFill (0xFF0000);
graphics.drawRect (0, 0, 100, 100);

With the code in place, use Project > Run from the menu, Ctrl+F5 (Command+Alt+Enter on a Mac) on the keyboard. Continue reading Getting Started with Haxe/Flash in MonoDevelop

NME Game Example: “Pirate Pig”

If you are familiar with webOS, you may have heard of Enyo, a Javascript framework which powers many of the built-in applications for the HP TouchPad. Recently, Enyo was released as open-source software, so you can use the framework on more platforms in addition to webOS, such as iOS, Android or BlackBerry.

If you need to create an application, Enyo is a choice you may want to consider. You can learn more at enyojs.com, and if you are a fan of Haxe-based development, there are externs for Enyo 1.0 on haxelib which can enable you to use the framework while also benefiting from the many advantages of haxe JS.

Although most of the samples for Enyo are applications, at least one sample, “Pirate Pig,” is that of a game. It is a quirky game that uses similar mechanics to Bejeweled. You can view the original version here:

http://www.enyojs.com/samples/piratepig/

The Challenge

I wanted to discover how difficult it would be to create the same game using NME. I would not use any of the original Javascript source code, but instead would use the same assets to recreate the same mechanics.

In the spirit of a game jam, I wanted to create the game in two days. In the interest of supporting my wife, I wanted to also keep it during the day instead of working late. Continue reading NME Game Example: “Pirate Pig”

Embedding SWFs Makes NME Meme-Friendly

The latest SWF embedding support in NME makes it that much easier to recreate (or create!) your favorite meme:

var cat = new NyanCatAnimation ();
addChild (cat);
 
var theme = Assets.getSound ("assets/Nyan Cat Theme.mp3");
theme.play (0, -1);

When you mark a symbol in Flash to “Export for ActionScript”, you can choose  a class name. In the example above, my MovieClip was exported using “NyanCatAnimation” as the class name. Continue reading Embedding SWFs Makes NME Meme-Friendly

7 Useful Utilities For Your Next NME Application

I have been going through code library to find more tools I could bring to Haxe. I am happy to share some new libraries, as well as a few old ones, which may be helpful in your next (or current) NME (or Haxe) project.

Actuate

If you have used NME before, you probably have heard of Actuate. Simply put, Actuate is a “tween” library, designed to automatically transition objects from one value to another. This works for animation, of course, but is also useful for fading sound, adjusting filters or setting a quick timer.

Two years ago, Actuate was my bread-and-butter library, like (I would argue) tween libraries should be for a Flash developer. It was the culmination of using many kinds of libraries in the best, and actually performed faster than GreenSock’s TweenMax and TweenLite libraries by a fair margin. Most of all, I made sure to give Actuate a “set it and forget it” reliability I had come to appreciate from using Zeh Fernando’s famed Tweener library. Continue reading 7 Useful Utilities For Your Next NME Application

Use SWF Assets in NME — Cross-Platform!

Hugh Sanderson made some amazing SWF parsing code in the GM2D game library. When he isn’t making NME awesome, he is improving HXCPP, GM2D, or enjoying well-earned time with his family.

I used his SWF parsing code for the first time last week. Since that time, I have merged the code into NME and have begun the process to find any areas where it can improve and where it can shine even brighter.

I am very excited about what this will mean for NME. Sprite sheets will always be one of the fastest ways to render, but SWF support will mean sprite sheets are an option, not a requirement when creating animation for NME. You could even load a SWF and generate a sprite sheet at runtime, or we could build a cross-platform tool in NME that could import SWF files and help create layouts and optimized graphic assets.

Bottom-line: The ability to load SWF files at runtime in NME, whether you publish to Flash or C++, eliminates one of the  long-standing “trade-offs” to using NME to create games or applications. Continue reading Use SWF Assets in NME — Cross-Platform!

NME 3: Flash, C++ and now HTML5

From the beginning, Haxe was created to be a “multi-platform programming language.”

NME relies on Haxe for reliable compilation to Flash and C++, but these aren’t the only languages Haxe supports. Meanwhile, a project (you may have heard of) called Jeash used Haxe to mirror the Flash API… but for Javascript.

For everyone who is excited by HTML5, you can now publish to Flash, C++ and Canvas as easy as…

haxelib run nme test MyProject.nmml flash
haxelib run nme test MyProject.nmml ios -simulator
haxelib run nme test MyProject.nmml webos
haxelib run nme test MyProject.nmml android
haxelib run nme test MyProject.nmml cpp
haxelib run nme test MyProject.nmml cpp -64
haxelib run nme test MyProject.nmml html5

Here is my previous “Actuate Example,” running in Flash and in Canvas as a comparison:

http://www.joshuagranick.com/examples/actuate/circles/flash/
http://www.joshuagranick.com/examples/actuate/circles/canvas/

Benchmarking NME with BunnyMark

A few months ago, a friend recommended that I try BunnyMark, a cute rendering benchmark. I have meant to port it to Haxe so I could use it to benchmark NME, so today I decided to give it a whirl.

The first two tests were performed on my laptop, using Flash Player and a compiled Windows application, using NME. The first test uses separate bitmap objects for each of the bunnies, so rendering performance relies more heavily on the display list.
Continue reading Benchmarking NME with BunnyMark