0

这是我的代码:

public class Schem
{
    public var info:String="";
    private var ro:RemoteObject = new RemoteObject("Hibernatetest");



    public function Schem()
    {       
        ro.endpoint = "http://jesus/blazeds/messagebroker/amf";
    }

    public function loadCurrentSchem():void
    {


        var token:AsyncToken = ro.getCells();
        token.addResponder(new AsyncResponder(onResult,onFault));

        info = info + "Loader Called ...";


    }

    private function onResult(event:ResultEvent,token:Object):void {
        var cellList:ArrayCollection = event.result as ArrayCollection;
        info = info + "Resulthandler Called";

    }

    private function onFault(event:FaultEvent,token:Object):void
    {

    }
    //Eventhandlers


    //Getters, Setters


}

通过检查我发现的信息字符串,当我调用 loadCurrentSchem() 时,该类没有到达 Resulthanlder。这是为什么?

4

1 回答 1

0

首先,我看不出你在哪里有异步令牌的优势?异步令牌是一种将有关单个查询及其状态的所有信息封装在单个对象中的模式。你可以在这里阅读更多。

在您的情况下,您只需要获取查询结果事件。最好的方法是使用RemoteObject's 事件(参见文档)。所以代码将如下所示:

public class Schem
{
    public var info:String="";
    private var ro:RemoteObject;



    public function Schem()
    {
        ro = new RemoteObject("Hibernatetest");
        ro.endpoint = "http://jesus/blazeds/messagebroker/amf";
        ro.addEventListener(ResultEvent.RESULT, onResult);
        ro.addEventListener(FaultEvent.FAULT, onFault);
    }

    public function loadCurrentSchem():void
    {
        ro.getCells();
        info = info + "Loader Called ...";
    }

    private function onResult(event:ResultEvent):void {
        var cellList:ArrayCollection = event.result as ArrayCollection;
        info = info + "Resulthandler Called";
    }

    private function onFault(event:FaultEvent):void
    {
        info = info + "Errorhandler Called";
    }
    //Eventhandlers


    //Getters, Setters
}
于 2011-05-26T10:43:46.257 回答