AS3 httpservice - pass arguments to event handlers by reference
- by Shawn Simon
I have this code:
var service:HTTPService = new HTTPService();
if (search.Location && search.Location.length > 0 && chkLocalSearch.selected) {
service.url = 'http://ajax.googleapis.com/ajax/services/search/local';
service.request.q = search.Keyword;
service.request.near = search.Location;
} else
{
service.url = 'http://ajax.googleapis.com/ajax/services/search/web';
service.request.q = search.Keyword + " " + search.Location;
}
service.request.v = '1.0';
service.resultFormat = 'text';
service.addEventListener(ResultEvent.RESULT, onServerResponse);
service.send();
I want to pass the search object to the result method (onServerResponse) but if I do it in a closure it gets passed by value. Is there anyway to do it by reference without searching through my array of search objects for the value returned in the result? Sorry, this is simple but it's been a long day...