我正在尝试RestClientLib并且我添加的事件监听器没有被触发。我不明白为什么。有人有什么想法吗?
var restClient = new RestClient();
protected function btnInfo2_clickHandler(event:MouseEvent):void
{
restClient.host = "somehost";
restClient.port = "443";
restClient.secure = true;
restClient.setupRequest(RestClient.METHOD_GET, "somemethod");
restClient.addparam("format","json");
restClient.addEventListener(RestEvent.RESULT, onResult);
restClient.sendrequest();
}
protected function onResult(event:RestEvent):void
{
trace("onResult");
}
如果我在 RestClient 的源代码中放置一个断点:
private function onResult(event:ResultEvent,token:Object=null):void
{
trace("Reached onResult handler");
var rawData:String = String(event.result);
event.token.dispatchEvent(new RestEvent(RestEvent.RESULT, RestClient.SUCCESS, rawData,event.statusCode,null,event.token, true));
}
实际接收到数据,但未传播事件。
我也尝试将气泡设置为真,但无济于事。