HTTPService/ResultEvent with Flex 3.2 versus Flex >= 3.5

北城以北 提交于 2019-12-06 03:43:43

It is useful to go through the source if you get into this. On OS X the rpc classes are here: /Applications/Adobe Flash Builder Beta 2/sdks/3.4.1/frameworks/projects/rpc/src

Inside mx.rpc.http.HTTPService there is indeed an inner-class named HTTPOperation. It extends mx.rpc.http.AbstractOperation which in turn extends mx.rpc.AbstractOperation. Inside AbstractOperation is a getter method get service which looks to return what you need.

Since HTTPService is an inner-class it is effectively private so you'll need to cast to an AbstractOperation (either mx.rpc.http.AbstractOperation or mx.rpc.AbstractOperation).

So something like:

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

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

edit: I take it back! Looks like Adobe is sending null for the service when it calls the super when constructing the HTTPOperation. The HTTPService is therefore only cached in the private variable httpService. I have no idea why they hide it from you but it looks like you'll have to keep your own reference around.

Arrj

I solved this problem for myself. There are some properties in HTTPService that are available from AbstractOperation. For example, I use property request which is an Object:

myService.request["service"] = myService;

And later, when I get Event which has HTTPOperation in event.currentTarget, I get my HTTPService in such way:

 var eventService : HTTPService = HTTPService( AbstractOperation( event.currentTarget ).request["service"] );
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!