I have a proxy with a delegate class loading a xml file using HTTPService. The proxy implements the IResponder interface and an instance of the proxy is passed to the delegate class. My problem is that the proxy's result function is fired twice and the same with the fault function if the loading fails. Anyone have any idea why ?
Proxy code: override public function onRegister():void { if (Log.isDebug()) logger.debug("onRegister"); var delegate:DefaultModuleLoaderDelegate = new DefaultModuleLoaderDelegate(this); delegate.loadModuleConfig(); }
Delegate code: /** * Constructor. * @param responder IResponder from caller. */ public function DefaultModuleLoaderDelegate(responder:IResponder) { if (Log.isDebug()) logger.debug("Constructor"); this.service = new HTTPService(); this.service.contentType = HTTPService.CONTENT_TYPE_XML; this.service.url = XMLFILE; this.service.resultFormat = HTTPService.RESULT_FORMAT_E4X; this.responder = responder; }
/** * Worker function. Responsible for loading xml file. */ public function loadModuleConfig():void { if (Log.isDebug()) logger.debug("loadModuleConfig"); try { token = this.service.send(); //Making sure the response is delegated upwards. token.addResponder(this.responder); } catch (error:Error) { if (Log.isError()) logger.error(error.getStackTrace()); ExtendedAlert.showExtended("defaultmodule.xml is missing.", "Fatal error", 4, null, null, ExtendedAlert.ICON_ERROR48, 4); } }
|