Search code examples
apache-flexflash-builderurlrequest

Is it possible to use a var in a URLRequest


During development I have to test using several different hosts. It is a pain to have to change the IP address everywhere I use navigateToURL or in an mx:HTTPService.

I would like to set a var with the IP...

public var hostIP:String = "192.168.1.100";

Then later I instead of doing...

navigateToURL(new URLRequest('http://192.161.1.100/JudgesRegistration.html?email='+email+'&password='+password),'_self')

I would like to do something like...

navigateToURL(new URLRequest('http://'+hostIP+'/JudgesRegistration.html?email='+email+'&password='+password),'_self')

Then I would only have to change the IP assigned to hostIP instead of throughout the project. Unfortunately I can't figure out how to imbed the var in the URL string. Is this even possible?

Here is what my HTTPService looks like...

<mx:HTTPService 
    id="emailPasswordService"
    method="POST"
    url="http://192.168.1.100/chaos/emailPassword?output=xml"
    makeObjectsBindable="true"
    result="emailPasswordSuccess(event)"
    fault="httpServiceFaultHandler(event)"
    showBusyCursor="true"
    resultFormat="e4x">
</mx:HTTPService>

Thanks,

John


Solution

  • This should simply just work.

    navigateToURL(new URLRequest('http://' + hostIP + '/JudgesRegistration.html?email=' + email + '&password=' + password),'_self')
    

    Are you finding any errors?