Heres my code:
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开发者_Go百科:FaultEvent,token:Object):void
{
}
//Eventhandlers
//Getters, Setters
}
By inspecting the info String i found out, that the class doesnt reach the Resulthanlder, when i call loadCurrentSchem(). Why is that?
First of all I can't see where you have advantages of async token? Async token is a pattern to incapsulate all the information about a single query and its state in a single object. You can read more here.
In your case all that you need is to get query result event. The best way to do that is to use RemoteObject
's events (see documentation). So the code will look like the following:
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
}
精彩评论