i have a function which retrieves values from a webservice , then loops through the returned values and for each returned value does another webservice lookup.
Im having a problem however that when i make the second webservice call within the for loop that the function does not wait for the reuslt and just keeps processing and in turn giving me no value
the code looks like this;
private function getResult(e:ResultEvent):void{ var lengthOfResult:int = e.result.length; var arrayCollResults:ArrayCollection = new ArrayCollection(); var resultArray:Array = new Array(e.result); for(var i:int = 0 ; i < lengthOfResult; i++){ var currentName:String = e.result[i].toString(); arrayCollResults.addItem(e.result[i] + ws.getMatches(currentName)); } acu.dataProvider = arrayCollResults; }
what can i do to insure that the value of ws.getMatches(currentName) actually returns a value before moving to next line?
The documentation here indicates that you do not call the Web service directly, you need to set up an event listener and handle the response on completed delivery.
From the section ‘Calling web services in ActionScript’:
Put the ‘arrayCollResults.addItem(…)’ segment in the result handler for your ws.getMatches() event.