haXe AS3 Code Generator
haXe have its own native Flash9 compiler, but there are some cases when you want to deliver AS3 source code to either your company clients or people not using haXe. In that case, haXe enables you to generate the complete corresponding AS3 source code from a set of haXe classes.
Instead of using :
haxe -swf-version 9 -swf output.swf .....
Simply write :
haxe -as3 as3_src ....
This will generate all AS3 classes in the as3_src directory.
If you are using -main, it will also generate a as3_src/__main__.as class that will execute the program entry point.
To compile the generated AS3 Source code, simply use the MXMLC commandline program available as part of the free Flex2 SDK :
cd as3_src mxmlc -output as3.swf __main__.as
Incompatibilities
There are not so much incompatibilities, only the ones that you should know when using Flash9 compare to using Flash 6-7-8.
In particular, the Int, Float and Bool values in haXe are allowed to be null, while this is not the case in AS3/Flash9. If you still want to use null values (for example when having optional parameters of one of these three types), you will have to change the type to Null<Int>, Null<Float> or Null<Bool>.
This will inform haXe that the Flash9 value type can be null. You can safely assign a Int to a Null<Int>, but assigning a Null<Int> to Int will convert null to 0, so you have to be careful to test for null first. Null values are converted to the * Flash9 type, so making calculs on them is significantly slower than basic types.
Problems
If you experience any problem with the AS3 code generator, please try to make a small example reproducing the problem and send it on the haXe list. The problem should be fixed very quickly.