I have a big loop in actionscript that sends a lot of data to a URL:
for(var i=0;i<1000;i++) {
var request:URLRequest = new URLRequest();
request.url = url;
request.method = URLRequestMethod.POST;
request.data = data;
var loader:URLLoader = new URLLoader();
loader.load(request);
}
The problem is that URLLoader can only make asynchronous calls, it sends all these thousands of requests at once, which kill the web server.
And this is a little strange. Assume that the cycle runs for 5 minutes. There are no requests to the web server for the whole 5 minutes, then at the end they are all sent immediately. I already tried everything I could think (empty loops, callbacks, delays) - nothing helps. All requests are sent immediately no matter what.
How to make requests synchronous, so it will send one request after another? Can anyone suggest any solution?