我正在使用加载程序从 WMS(Web 映射服务)请求图像。有一个有效的请求,一切都很好。
当向 WMS 发出错误请求时,通常会返回标准异常文档 (XML)。但是,当发出错误请求时,加载程序不会触发任何事件(特别是 Complete 或 IOError 事件)。
有没有人对我如何捕获任何不是可能返回的图像有任何建议?
override protected function loadMapImage(loader:Loader):void
{
// update parameter values
_params = new URLVariables();
_params.request = "GetMap";
_params.format = "image/png";
_params.version = "1.1.1";
_params.layers = this.layers;
_params.styles = "";
_params.transparent = "TRUE";
_params.bbox = map.extent.xmin + "," + map.extent.ymin + "," + map.extent.xmax + "," + map.extent.ymax;
_params.srs = "EPSG:" + map.spatialReference.wkid;
_params.width = map.width;
_params.height = map.height;
_urlRequest = new URLRequest(this.url);
_urlRequest.data = _params;
configureListeners(loader.contentLoaderInfo);
loader.load(_urlRequest);
}
private function configureListeners(dispatcher:IEventDispatcher):void
{
//dispatcher.addEventListener(Event.INIT, initHandler);
//dispatcher.addEventListener(Event.UNLOAD, unloadHandler);
dispatcher.addEventListener(Event.COMPLETE, completeHandler);
//dispatcher.addEventListener(Event.OPEN, openHandler);
//dispatcher.addEventListener(ProgressEvent.PROGRESS, progressHandler);
//dispatcher.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
//dispatcher.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
//dispatcher.addEventListener(Event.ACTIVATE, activateHandler);
//dispatcher.addEventListener(Event.DEACTIVATE, deactivateHandler);
}
private function ioErrorHandler(event:IOErrorEvent):void
{
trace('ioErrorHandler event');
}
private function completeHandler(event:Event):void
{
trace('completeHandler event');
}