AS3 httpservice - pass arguments to event handlers by reference

Posted by Shawn Simon on Stack Overflow See other posts from Stack Overflow or by Shawn Simon
Published on 2010-04-09T22:36:50Z Indexed on 2010/04/09 22:43 UTC
Read the original article Hit count: 347

Filed under:

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...

© Stack Overflow or respective owner

Related posts about as3