acCountries = srv.getAllCountries.lastResult
it looks like your assigning a result to a arrayCollection, but haven't even called for the data?
Thanks, but it doesn't seem to matter whether assign the variable or make the data services call first. In each case, it only works if I execute the code twice.
Try to use the below approach instead of the appraoch you adopted.
public var srv:RemoteObject;
private function getAllCountries():void
if(srv == null)
private function countriesResultHandler(result:ResultEvent)
//Here inspect the result object by debugging and replace the below line accordingly
acCountries = result.countries;
private function countriesfaultHandler(fault:FaultEvent)
"Fault:" + fault.message);
In the approach you used you are binding the data to the ArrayCollection by making use of the lastResult object.
But you are using the below line and you are sending the result at the same time .....
acCountries = srv.getAllCountries.lastResult;
Here you don't know when the acCountries arraycollection will bound to the lastResult object . Since it is a asynchronous operation so by the first time you are checking the acCountries arraycollection you are not having any data. Its always better and good appraoch to use response event handlers like the way I used so that you will exactly know when the response/result occured and if any fault or so.
If this post answers your question or helps, please kindly mark it as such.
Hope this will make things clear...
Yes, it appears the asynchronous data services call was not populating the arraylist in time. It is working with the event listener.