Hi,

just responded to this question in SOF:

https://stackoverflow.com/questions/63546819/recode-flex-urlrequest-and-navigatetourl-form-emulation-to-royale-js/63558866#63558866

since I really don't use URLRequest, I got the info from various emails and
urls, so hope others can ensure all is ok.

I think we have a problem with no POST support in BrowserWindow? Although
is done in HTTPService I think is confusing for users and most of the time
unusable. We had many threads over the years with similar problem ( I think
I saw 3 or 4)

@Andrew Wetmore <[email protected]> you can have this info (if rest think
is accurate) and add it to royale-docs?

----- My Response in SOF is this:

equivalente code for `URLRequest`:

```actionscript
var u:URLRequest = new URLRequest("http://domain.foo";);
navigateToURL(u,"_blank");
```

in Apache Royale is `BrowserWindow`:

```actionscript
import org.apache.royale.core.BrowserWindow;

var u:String = "http://domain.foo";;
BrowserWindow.open(u, "_blank");
```

To pass variables you need to do via `GET`method: `"
http://domain.foo?variable="; + key`.

To use `POST` method use `HTTPService` class from `Network` SWC instead:

```actionscript
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();
```

Optionally in case you need to deal with CORS you can add
`CORSCredentialsBead` bead to the `HTTPService`:

```actionscript
service.addBead(new CORSCredentialsBead(true));
```

(Note: code is untested, please report if all is ok so we can improve this
response and code snippet, thanks)

-- 
Carlos Rovira
http://about.me/carlosrovira

Reply via email to