是否可以在 URLRequest 中使用 var
在开发过程中,我必须使用几个不同的主机进行测试。在我使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这应该可以正常工作。
您发现任何错误吗?
This should simply just work.
Are you finding any errors?
我认为您正在寻找的是静态类常量。您可以声明一个具有可在项目中随处访问的常量的类。
一旦你有了这样的类,你就可以在任何地方调用 HOST_IP 常量并检索它的值。前任。:
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.
Once you have a class like that, you can call the HOST_IP constant anywhere and retrieve its value. Ex.: