等效代码URLRequest
:
var u:URLRequest = new URLRequest("http://domain.foo");
navigateToURL(u,"_blank");
在 Apache Royale 中是BrowserWindow
:
import org.apache.royale.core.BrowserWindow;
var u:String = "http://domain.foo";
BrowserWindow.open(u, "_blank");
要传递变量,您需要通过GET
方法:"http://domain.foo?variable=" + key
.
要改用SWC中的POST
方法使用HTTPService
类:Network
import org.apache.royale.net.HTTPConstants;
import org.apache.royale.net.HTTPService;
import org.apache.royale.net.URLVariables;
// add the variables to send
var urlVars:URLVariables = new URLVariables();
urlVars.set("variable", key);
// create the httpservice instance
var service:HTTPService = new HTTPService();
service.url = "http://domain.foo";
service.method = HTTPConstants.POST;
service.addEventListener("complete", resultCallback);
service.addEventListener("ioError", faultCallback);
// add the variables
service.contentData = urlVars;
// trigger the service
service.send();
或者,如果您需要处理 CORS,您可以将CORSCredentialsBead
珠子添加到HTTPService
:
service.addBead(new CORSCredentialsBead(true));
(注意:代码未经测试,如果一切正常,请报告,以便我们改进此响应和代码片段,谢谢)