本文介绍了的HTTPService /的ResultEvent使用Flex 3.2与Flex的> = 3.5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

通过设计decission或什么那么曾经的Adobe改由HTTPService对象打响的ResultEvent的内容。

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

看看下面的例子:

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
}

它的工作原理是使用Flex 3.2的魅力。但是,当我尝试使用Flex 3.5或Flex 4.0编译它的作为将event.target HTTPService在的为空。

我想通了,就是将event.target现在的 HTTPOperation 的一个实例。这很有趣,因为我无法找到的 HTTPOperation 的在langref。但是,我认为Flash Builder的调试手段是的 mx.rpc.http.Operation 的。

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.

调试器还显示,将event.target 的具有私有属性的的HTTPService 的这是我期望能获得与将event.target 的实例。但是它是私有的,所以的 event.target.httpService 的是行不通的。

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.

如果我只是想删除的事件监听我可以施展的将event.target 的作为的的EventDispatcher 的。但我需要使用从的的HTTPService 的方法。

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

所以:我如何从的ResultEvent获得的的HTTPService 的实例

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

任何帮助将是AP preciated。谢谢!

Any help would be appreciated. Thanks!

学家

推荐答案

我解决了这个问题我自己。有在的HTTPService 某些属性可以从返回AbstractOperation 。比如,我用财产要求这是一个对象:

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;

后来,当我得到的事件有 HTTPOperation event.currentTarget ,我让我的的HTTPService 以这样的方式:

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"] );

这篇关于的HTTPService /的ResultEvent使用Flex 3.2与Flex的> = 3.5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 14:43