Sunday, July 26, 2009

starting haxe. (stuff i want to remember)

I've been tinkering with a flash project recently. Actually haxe, so it's only linux tools -- VI, and the command line -- not the GUI interface people normally associate with flash. This post is a summary of how to get started with haxe using only the command line, and a project containing flash stuff I want to remember.
To start, here's a gist of shell commands that will set up haxe on an ubuntu machine. The installers from the haxe website work fine for windows and mac (and I think 32 bit linux).

Haxe has a slightly different syntax from actionscript 3, but for most things it is identical. These docs are very good, and better than the adobe site, I have that page open always when working with haxe. I also grabbed an "actionscript.vim" from the internet somewhere and put it in ~/.vim/syntax/ for syntax highlighting and added this line to my .vimrc:
autocmd BufRead *.hx set filetype=actionscript

Then compilation and code is simply a matter of following this.

If you only look at haxe/flash occassionally, some stuff can be less than obvious. I've started a github project as a testing ground where I can record the stuff I figure out.
Currently it has examples of:

+ call javascript from flash (
+ call flash from javascript (ExternalInterface.addCallBack())
+ add an image from a (local) url
+ keyboard events
+ interact with bitmap data of image.
+ style a text field.

all in a single .hx file. Most of those are fairly simple, they just require the correct incantation. There's a version of this running on my work machine here to demo this stuff. The possible interactions are mostly listed as instructions in either the HTML or the flash movie in that page.
To build the flash(9) movie, just type 'haxe build.hxml' in the learnflash/ directory. Commenting out the '--no-traces' line in build.hxml will cause any trace() call to be sent to firebug--this is extremely useful for debugging.

I'll probably add more as stumble upon it.