I’m trying the RestClientLib and my added eventlistener isn’t fired.
I can’t see why. Anyone has any ideas?
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");
}
If I put a breakpoint inside the source for the 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));
}
the data is actually received, but the Event is not propagated.
I have also tried settings bubbles to true, but no avail.
Looks like the event is dispatched on the event.token. This token looks like it is returned by the sendrequest method. So you’d add the listener like this:
Hope that works.