Software and Technology Ramblings

May 17, 2009

Automatic Switching of Environments with Adobe AIR

Filed under: AIR, Flex — Doug Hays @ 11:31 pm

There is an issue with AIR application development to which I still have not found an official answer.

I just need to switch between http://localhost and http://fakeproductionurl.com depending on whether I was running in Flex Builder (via adl).

I found all sorts of articles about using conditional compilation (yikes) and reading XML files (I’m too lazy).

This is what I ended up using:

if (NativeApplication.nativeApplication.publisherID != "") {
   return "http://fakeproductionurl.com";
}
else {
   return "http://localhost";
}

It doesn’t give you the ability to switch between 3+ different environments, but it’s a very easy way to toggle between development / production environments.

Powered by WordPress