Question

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

Was it helpful?

Solution

This should simply just work.

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

Are you finding any errors?

OTHER TIPS

I think that what you are looking for are static class constants. You can declare a class that has constants which are accessible everywhere in your project.

package <any location you want>
{
    public class HostInfos
    {
        // static constants
        public static const HOST_IP:String = "192.168.1.100";

        public function HostInfos() {}
    }
}

Once you have a class like that, you can call the HOST_IP constant anywhere and retrieve its value. Ex.:

navigateToURL(new URLRequest('http://' + HostInfos.HOST_IP + '/JudgesRegistration.html?email='+email+'&password='+password),'_self')
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top