Posted by Doug Hays on the 17th of May, 2009 at 11:31 pm under AIR and Flex.    This post has 3,192 comments.

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.