Search code examples
actionscriptcompilationhaxetoken

Tokens in Haxe build process?


I'm using Haxe to make a few simple SWFs for RTMP video streaming. Everything is working great, but what I'd really like to do is tokenize a few properties so that the SWFs are compiled with environment specific properties ALA Ant.

E.G:

var host = "rtmp://localhost:1935/broadcasts";

Becomes:

var host = "@RTMP_ADDRESS@"

And then during compile, the token is substituted with an environment specific value- local.properties contains:

RTMP_ADDRESS=rtmp://localhost:1935/broadcasts

I've poked around in documentation and on forum posts and can't see how to do this, though I'm sure it's possible. Can anyone point me in the right direction?

Note: I considered using flashvars and managing the address in the web application, but that seems less efficient. If that's the better way to handle this please explain why.


Solution

  • It sounds a perfect case to use macros, which is in the nightly build of haxe. You can create a config file (maybe in xml format) inside your project, and in the body of your macro function you load the file and extract the String, finally return it as an expression.