1
var url:String = "http://www.[yourDomain].com/application.jsp";
var request:URLRequest = new URLRequest(url);

var variables:URLVariables = new URLVariables();
variables.exampleSessionId = new Date().getTime();
variables.exampleUserLabel = "guest";
request.data = variables;
request.method = URLRequestMethod.POST;

navigateToURL(request);

This example is the functionality I want to achieve, however i want to make this happen in the background. This code opens a window.

Writecoder
  • 613
  • 2
  • 8
  • 27

2 Answers2

1

You need to create a URLLoader and call its load() method to do stuff "in the background".

var url:String = "http://www.[yourDomain].com/application.jsp";
var request:URLRequest = new URLRequest(url);

var variables:URLVariables = new URLVariables();
variables.exampleSessionId = new Date().getTime();
variables.exampleUserLabel = "guest";

request.data = variables;
request.method = URLRequestMethod.POST;

var ldr:URLLoader = new URLLoader();
ldr.load(req);

If you're sending data back then you can manage this through an Event.

ldr.addEventListener(Event.COMPLETE, _dataBack);

function _dataBack(e:Event):void
{
    var vars:URLVariables = new URLVariables(e.target.data);
    //do stuff with vars

    removeEventListener(Event.COMPLETE, _dataBack);
}
Marty
  • 39,033
  • 19
  • 93
  • 162
1

sendToURL() ignores any response

www0z0k
  • 4,444
  • 3
  • 27
  • 32