Thursday, September 12, 2013

Installing openfl and haxe 3.0 on Ubuntu

Making the jump from using NME and haxe for cross platform development to using openfl led to a bit of a frustration. Trying to upgrade to haxe 3.0 and get openfl to install caused collisions between the old version and the new version. Especially frustrating was running  sudo haxelib run openfl setup and getting the the dreaded:
Called from ? line 1
Called from RunScript.hx line 798
Called from helpers/PathHelper.hx line 170
Called from C:\HaxeToolkit\haxe/std/neko/_std/sys/io/Process.hx line 88
Called from C:\HaxeToolkit\haxe/std/neko/_std/sys/io/Process.hx line 96
Uncaught exception - Process creation failure : haxelib
To correct all the issues, I did the following:
  1. remove every instance of haxe/neko/openfl you can find from your computer. Most of it should be symlinks in /usr/bin and files in /usr/lib/(haxe|neko)
  2. go to and download the Linux installer from the "install haxe" step. 
  3. Unpack the tar.gz file you just downloaded run the script in a console. It will fail on the last step because haxelib isn't anywhere in the path.
  4. type ln -s /usr/lib/haxe/std/tools/haxelib/haxelib haxelib to create a symbolic link to the haxelib tool in a place where it can actually be found.
  5. continue with the setup instructions and things should work from there.
After the installation, create a directory to test the samples, then use openfl create DisplayingABitmap in that directory to download the bitmap sample. Run the sample with openfl test flash and you should see a flash window (or browser) open with the openfl logo. If, like on my machine, x-shockwave-flash mime type was associated with totem (a video player) you can change that by editing /usr/share/applications/defaults.list and replace target for application/x-shockwave-flash to point to a desktop file for a flash player (I use flashplayerdebugger.desktop.) Once that is changed, openfl test flash will open the flash player correctly.