views:

466

answers:

2

In summary, I think my question is this:

How can I force hxcpp to compile haxe code for Flash 8 ?

Here's where I'm at. I'm new to haxe, and am trying to get a sample from here:

http://tilestudio.sourceforge.net/flash/Demo.html

to compile using hxcpp, in my tests to see how haxe compiled apps work on the iphone.

I've gotten other samples to compile fine and put them on the iphone, but when I compile this sample, it complains with things like:

Demo.hx:32: characters 17-53 : Class not found : flash.MovieClip
Demo.hx:42: characters 20-36 : Class not found : flash.Key
Demo.hx:44: characters 43-60 : Class not found : flash.Stage

and as I mentioned, this compiles fine using the following hxml file (flash.hxml):

-swf Demo.swf
-swf-lib DemoRes.swf
-main Demo.hx
-swf-header 480:320:100:808080

but fails as detailed above using this (cpp.hxml):

-main Demo.hx
-lib nme
-lib neash
-swf-lib DemoRes.swf
--remap neko:cpp
--remap flash:neash
-cpp cpp

So I think the problem is that hxcpp is targeting Flash version 9 swf's, and the haxe code is targetting Flash 8. I tried forcing it to accept Flash 8 syntax using "-swf-version 8" but it doesn't work (gives the same errors).

+1  A: 

Although Neash is quite complete I am not sure it does map 100% of the Flash API. That said you have for sure a problem with -swf-lib that will not work with Neash; that beacuse it is not possible to embed swf files in other platforms than flash. You have to manage your assets differently. Maybe in a not so distant future it will be possible to embed even swf resources, but first someone has to write a nice decompiler that transform them for the intended target.

Franco Ponticelli
Thanks for the comment! While embedding a swf using swf-lib for hxcpp may not work, I thought it might, since I got an example that loads a swf at runtime (usr/lib/haxe/lib/neash/1,0,1/samples/06-SWF) to compile and load on the iphone. The swf is very simple, but it loads and displays a circle bouncing along on some grass, and it works. So I thought that using a swf as a lib might work as neash was loading and parsing a simple swf for display, and that worked.
Brad Parks
Apparently I totally missed that part of the Neash API. Even so, the SWF in the example is loaded at runtime and not compile-time ... If your swf can be parsed correctly by Neash then the closest thing you have to emulate -swf-lib is embedding your asset as a resource: http://haxe.org/doc/advanced/resourcesThe example in the doc refers to a text file but you can use bytes as well.
Franco Ponticelli
@BradHi Brad,Do you have a tutorial on how you managed this? I'm trying to absorb everything I can on haXe/iPhone, but there's very little out there at the moment...Cheers
Paul
+1  A: 

I asked Hugh, the guy behind the hxcpp compiler part of Haxe that's doing all the haxe / iphone / hxcpp stuff, and he basically said that Flash 8 isn't an available target for hxcpp, just Flash 9 and up.... Thanks for the response Hugh!

http://gamehaxe.com/2009/08/17/switched-to-immix-for-internal-garbage-collection/#comment-309

Brad Parks