Pages

Monday, July 1, 2013

From NME to OpenFL with FlashDevelop

Right now OpenFL already up on the haxelib  so I could say that it's safe to use it now. For some , the migration process wouldn't be as smooth as one expect. Some problem like different build file type (NME use .nmml while OpenFL use .xml) and the support of OpenFL on FlashDevelop would cause a problem.

I've sucessfully migrated my NME project into OpenFL, it's not a big deal but maybe it can help they who don't know how to migrate :) 


First here's how to install OpenFL and FlashDevelop :
  1. Install haxe 3 from and the official site
  2. open the newly installed haxelib and install these libs: openfl, openfl-compatibility, openfl-tools,openfl-native,openfl-html5
  3. after those libs installed, run this command : haxelib run openfl setup 
  4. run additional setup command to setup each platform : openfl setup android, openfl setup blackberry, etc . If you already run nme setup [platform] previously , the setting would be saved in OpenFL
  5. The current release build of FlashDevelop doesn't support OpenFL project, so you need to install the dev build version of FlashDevelop. you can download it here
  6. if you select New Project in FlashDevelop you can see the OpenFL project can be created there.

Migrating NME Project to OpenFL Project

Using the new FlashDevelop we can migrate NME Project to OpenFL, but it need some configuration changes in .nmml file to do so.
  • change .nmml file extension in your NME project into .xml 
  • change <haxelib="nme"/> into <haxelib="openfl"/>
  • add <haxelib="openfl-compatibility"/> so OpenFL will recognize all the old nme package
  • looks like <haxelib="actuate"/> is necessary in OpenFL so don't forget to add that (Edit: turns out It's not really necessary if you don't use actuate)
  • I'm not sure if this one necessary or not but you can delete all <ndll/> tags without problem (except your own ndll of course)
  • This one too , delete the old <haxeflag/> tag and change with this one <haxeflag name="-dce std" if="haxe3" />
  • Last, we need to tell FlashDevelop to use the .xml file as the build file. Right click Project -> Properties . On the output file, change the application.nmml extension to application.xml
  • Try to run the project. It should be no problem now.


Other notes
  • check the haxe 3 migration  for some feature changes like Maps and properties
  • haxe 3 use different haxelib repo than haxe 2. so make sure that your lib that you use is  exist in lib.haxe.org 
  • some library like spritesheet changes it's package name so you need to be careful about that.
for the end note, OpenFL is a great framework with so many potential. so don't hestitate to use it and keep creating awesome things . Cheers! :)