How to know if files is executing on local or sever

On most of my projects I end up having a dynamic xml for online testing, and an .xml file when I work locally.

What I do is having all the config vars on the top of my code, and comment depending wether I’m working locally or on the server.

as en example

//server
xml_file = “http://mydomain.com/mywebservice.php

//local
xml_file = “myfile.xml”

What would be really handy for me, instead of commenting each block each time, would be having a conditional:

if(we’re online){
xml_file = “http://mydomain.com/mywebservice.php
} else {
xml_file = “myfile.xml”
}

… but I don’t know how I can approach that.

Any ideas?

TIA

I like to set a create a global file for the project called something like local_settings.php that isn’t tracked by the SCM, which includes constants such as DEBUG and LIVE. When this file is included elsewhere, you can easily evaluate these in conditionals to act based on the local settings.

Try this;


var path:String = this.loaderInfo.url
			if(path.search("http") == -1){
				//you are not online
				
			}