A small trick when developing flex code that talks to hosting server

I often develop my flex code on a machine that is not running a web server. So I have to hardcode the IP of a working server when I need to pull data from the hosting server.

This can be a pain because before you checkin the code you have to remember to change the method of pulling the IP address.

So here is my solution var domain:String=mx.utils.URLUtil.getServerName(url); var port_nbr:int=mx.utils.URLUtil.getPort(url); if (flash.system.Security.sandboxType == "localTrusted") { Alert.show("In Development mode:"+domain+","+port); webService.wsdl="http://10.0.0.60:3000/services/wsdl"; } else { webService.wsdl="http://"+domain+":"+port+"/services/wsdl"; } Obviously this is for web services but this technique can be used for sockets as well.

March 21, 2008| Tags :
X

Comments Section

Feel free to comment on the post but keep it clean and on topic.

comments powered by Disqus

About Me

Tommie Jones Software Development for Linux/Unix since 1995. I've done everything from Perl,C/C++,Java,Flash,php, ruby and currently node.js. Always interested in pushing technology one step further than expected.

atlantageek.github.com