PDA

View Full Version : URLRequest delay ?


Gubb
10-06-2008, 02:10 PM
Hi, i'm creating an application where I want to iterate through an array of objects, and update their value in a database, the reading from the database and updating it one post at the time goes without problems, BUT, when i want to update all of the post at the same time, only the last object in the array gets updated.


function updatePos(e:Event):void
{
var tmpLoader:URLLoader = new URLLoader();
for(var i:uint = 0; i <= usrArray.length; i++)
{
var tmpString = "http://localhost:1492/Lab3/Lab3Service.asmx/updatePos?name=" +usrArray[i]._name +"&x=" +usrArray[i].x +"&y=" +usrArray[i].y;
tmpLoader.load(new URLRequest(tmpString));
}
}


Could this be due to some kind of delay/"lag" while contacting the webservice and therefore only the last sent URL-request gets processed correctly ? If that's the case, how could i make sure that the previous request gets completed before the next one starts ?

Thanks. :)

wvxvw
10-06-2008, 02:57 PM
You have to listen to Event.COMPLETE on URLLoader instance. Each time it fires you have to feed it new request for the next field you want to update. Although some browsers may handle several simultaneous down / up loads, and some (like Opera) have UI to set that number, average user wouldn't change hes/r settings to match your application (probably, s/he won't even know how to do it).

Gubb
10-06-2008, 04:14 PM
aaw, haha..of course. just me being retarded. :P thank you wvxvw!