HTTPService/ResultEvent with Flex 3.2 versus Flex >= 3.5

Posted by Julian on Stack Overflow See other posts from Stack Overflow or by Julian
Published on 2010-06-09T19:05:51Z Indexed on 2010/06/09 22:12 UTC
Read the original article Hit count: 503

Hey everybody,

through a design decission or what-so-ever Adobe changed the content of the ResultEvent fired by a HTTPService Object.

Take a look at following example:

var httpService:HTTPService = myHTTPServices.getResults();
httpService.addEventListener(ResultEvent.RESULT,resultHandler);
httpService.send();

/**
 * Handels the login process
 */
function resultHandler(event:ResultEvent):void
{
    // get http service
    var httpService = (event.target as HTTPService);

    // do something
}

It works like a charm with Flex 3.2. But when I try to compile it with Flex 3.5 or Flex 4.0 event.target as HTTPService is null.

I figured out that event.target is now an instance of HTTPOperation. That is interesting because I can't find HTTPOperation in the langref. However, I think what Flash Builder's debugger means is mx.rpc.http.Operation.

The debugger also shows that event.target has a private attribute httpService which is the instance I expected to get with event.target. But it's private, so event.target.httpService doesn't work.

If I only want to remove the EventListener I can cast event.target as EventDispatcher. But I need to use methods from HTTPService.

So: How can I get the HTTPService instance from the ResultEvent?

Any help would be appreciated. Thanks!

J.

© Stack Overflow or respective owner

Related posts about actionscript-3

Related posts about flex3