是否可以在 URLRequest 中使用 var

发布于 2024-12-23 03:14:27 字数 1003 浏览 3 评论 0原文

在开发过程中,我必须使用几个不同的主机进行测试。在我使用 navigatorToURL 或 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>

谢谢,

约翰

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夜夜流光相皎洁 2024-12-30 03:14:27

这应该可以正常工作。

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

您发现任何错误吗?

This should simply just work.

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

Are you finding any errors?

仙女山的月亮 2024-12-30 03:14:27

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

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

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')
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文