0

在开发过程中,我必须使用几个不同的主机进行测试。在我使用navigateToURL 或mx:HTTPService 的任何地方都必须更改IP 地址是一件很痛苦的事情。

我想用IP设置一个var ...

public var hostIP:String = "192.168.1.100";

然后后来我没有做...

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

我想做类似...

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

然后我只需要更改分配给 hostIP 的 IP,而不是整个项目。不幸的是,我不知道如何将 var 嵌入到 URL 字符串中。这甚至可能吗?

这是我的 HTTPService 的样子......

<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>

谢谢,

约翰

4

2 回答 2

1

这应该只是工作。

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

您是否发现任何错误?

于 2011-12-27T03:57:41.847 回答
1

我认为您正在寻找的是静态类常量。您可以声明一个具有在项目中随处可访问的常量的类。

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

        public function HostInfos() {}
    }
}

一旦有了这样的类,就可以在任何地方调用 HOST_IP 常量并检索它的值。前任。:

navigateToURL(new URLRequest('http://' + HostInfos.HOST_IP + '/JudgesRegistration.html?email='+email+'&password='+password),'_self')
于 2011-12-27T04:05:34.417 回答