OK I have an HTTPService that executes the dataLoaded(e:ResultEvent):void function whenever it gets a result from a send() call.
OK so If I call HTTPService.send() and then call HTTPService.send() again before the previous one receives a result, I end up repeatedly running dataLoaded() which is undesirable
What I want is if HTTPService.send() gets called before a previous call to it returns a result. I want to cancel the first call, and only process the result from the last call to HTTPService.send()
I hope this makes sense.
How can I do that??
Thanks!!
HTTPService has a cancel method. If you call it without its parameter, it should cancel the last invocation of the service. Give that a try and see if you're still getting undesired ResultEvents.
Use the existence of the ASyncToken to determine whether cancellation is appropriate.
private var _serviceCall:ASyncToken;
function callMyService(stuff:Object):void {
if (_serviceCall !== null) {
myService.cancel();
_serviceCall = null;
}
_serviceCall = myService.send(stuff)
}
Actually HTTPService can manage this for you. It has a concurrency property, which you should probably set to "last".
More info here: HTTPService#concurrency
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With