Is there alternative of flash AS3 sendToUrl(…) in haxe / OpenFL ?
No, but it would be great if we did. Perhaps we could do openfl.Utils
, which isn’t quite as nice as flash.utils
, but would allow import openfl.Utils.sendToURL;
(since Haxe does not allow a single static function to standalone in one file)
Perhaps URLLoader
could work, for example (from Adobe’s sample code):
var url:String = "http://www.yourDomain.com/application.jsp";
var variables:URLVariables = new URLVariables();
variables.sessionId = new Date().getTime();
variables.userLabel = "Your Name";
var request:URLRequest = new URLRequest(url);
request.data = variables;
trace("sendToURL: " + request.url + "?" + request.data);
try {
sendToURL(request);
}
catch (e:Error) {
// handle error here
}
to something like:
var url = "http://www.yourDomain.com/application.jsp";
var variables = new URLVariables();
variables.sessionId = new Date().getTime();
variables.userLabel = "Your Name";
var request = new URLRequest(url);
request.data = variables;
request.method = URLRequestMethod.POST;
var urlLoader = new URLLoader(request);