I started having a look at using HaXe a couple a days ago since it promises to be quite interesting.

haXe is a powerful modern language with many compelling features. It is aimed at giving developers a tool to create websites & applications in a single unified language.

It’s quite simple to install and if you use FlashDevelop as editor you’re pretty much set. I also took a look at some plugins for Eclipse, but they felt quite unfinished (granted most were still in beta). I tried Eclihx and HXDT.

Some useful info I found:

  • HaXe install dir: C:\Program Files\Motion-Twin\haxe\
  • Setting SWF properties using the HaXe compiler: -swf-header <header> : define SWF header (width:height:fps:color), i.e. “-swf-header 640:480:31:000000”
  • When your Main class is extending Sprite make sure to add it to the display list using: “Lib.current.stage.addChild(this);”
  • A nice tutorial on using SWCs with HaXe

Away3D in HaXe problem

I tried getting Away3D to run using Haxe, but it keeps on throwing an error at run time when I’m calling View3D.render() on every frame:

TypeError: Error #1034: Type Coercion failed: cannot convert flash.utils::Dictionary@157e1c1 to Function.
at MethodInfo-1076()[C:\Projects\HaXe\test03_away3d\src/away3d/haxeutils/HashMap.hx:50]
at away3d.core.utils::CameraVarsStore/reset()[C:\Projects\HaXe\test03_away3d\src/away3d/core/utils/CameraVarsStore.hx:147]
at away3d.containers::Scene3D/update()[C:\Projects\HaXe\test03_away3d\src/away3d/containers/Scene3D.hx:186]
at away3d.containers::Scene3D/onUpdate()[C:\Projects\HaXe\test03_away3d\src/away3d/containers/Scene3D.hx:85]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at away3d.containers::View3D/notifySceneUpdate()[C:\Projects\HaXe\test03_away3d\src/away3d/containers/View3D.hx:334]
at away3d.containers::View3D/render()[C:\Projects\HaXe\test03_away3d\src/away3d/containers/View3D.hx:921]
at com.dare.haxetest.core::Away3DTest/enterFrameHandler()[C:\Projects\HaXe\test03_away3d\src/com/dare/haxetest/core/Away3DTest.hx:222]

From a commit message in SVN it looks like there is a problem with using Dictionaries in HaXe. As the HashMap class still uses a Dictionary this error seems to be happening. I tried converting it to use the Hash class instead of a Dictionary, but that introduced other problems.