我如何处理Actionscript类中的异步令牌

| 这是我的代码:
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。这是为什么?     
已邀请:
首先,我看不到异步令牌在哪里有优势?异步令牌是一种将有关单个查询及其状态的所有信息封装在单个对象中的模式。你可以在这里阅读更多。 在您的情况下,您所需要做的就是获取查询结果事件。最好的方法是使用ѭ1的事件(请参阅文档)。因此,代码将如下所示:
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
}
    

要回复问题请先登录注册