HTTPService / ResultEvent with Flex 3.2 and Flex> = 3.5

Adobe has changed the contents of the ResultEvent launched by the HTTPService object through design dividing or something-ever.

Take a look at the 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 using Flex 3.5 or Flex 4.0 event.target, since the HTTPService is null.

I realized that event.target is now an instance of HTTPOperation. This is interesting because I cannot find HTTPOperation in langref. However, I think the Flash Builder debugger means mx.rpc.http.Operation.

The debugger also shows that event.target has a private attribute httpService, which is an instance that I expected to receive from event.target. But it is private, therefore event.target.httpService does not work.

EventListener, event.target EventDispatcher. HTTPService.

: HTTPService ResultEvent?

. !

J.

+3
2

, . OS X rpc : /Applications/Adobe Flash Builder Beta 2/sdks/3.4.1/frameworks/projects/rpc/src

mx.rpc.http.HTTPService HTTPOperation. mx.rpc.http.AbstractOperation, , , mx.rpc.AbstractOperation. AbstractOperation getter get service, , .

HTTPService , , AbstractOperation ( mx.rpc.http.AbstractOperation, mx.rpc.AbstractOperation).

- :

function resultHandler(event:ResultEvent):void
{
    // get the operation
    var operation:AbstractOperation = AbstractOperation(event.target);

    // get http service
    var httpService:HTTPService = HTTPService(operation.service);
}

: ! , Adobe null , HTTPOperation. HTTPService HTTPService. , , , .

+2

. HTTPService , AbstractOperation. , request, Object:

myService.request["service"] = myService;

, HTTPOperation event.currentTarget, HTTPService :

 var eventService : HTTPService = HTTPService( AbstractOperation( event.currentTarget ).request["service"] );
+2

Source: https://habr.com/ru/post/1749276/


All Articles