故障使用ActionScript装载机活动 [英] Trouble With ActionScript Loader Events

查看:127
本文介绍了故障使用ActionScript装载机活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用装载机工作,要求从WMS(Web地图服务)的图像。一切事情都很好,很正常了有效的请求。

在一个糟糕的请求发送到仓库管理系统,通常是返回一个标准异常文档(XML)。但是,加载程序不火时,一个坏的请求作出任何情况下(特别是完全或ioError事件的)。

有没有人有任何建议,我怎么可以捕获任何东西是不是可能会返回一个形象呢?

 覆盖保护功能loadMapImage(装载机:装载机):无效
{
//更新参数值
_params =新的URLVariables();
_params.request =的GetMap;
_params.format =图像/ PNG;
_params.version =1.1.1;
_params.layers = this.layers;
_params.styles =;
_params.transparent =TRUE;
_params.bbox = map.extent.xmin +,+ map.extent.ym​​in +,+ map.extent.xmax +,+ map.extent.ym​​ax;
_params.srs =EPSG:+ map.spatialReference.wkid;
_params.width = map.width;
_params.height = map.height;

_urlRequest =新的URLRequest(this.url);
_urlRequest.data = _params;

configureListeners(loader.contentLoaderInfo);

loader.load(_urlRequest);
}

私有函数configureListeners(调度员:IEventDispatcher,请):无效
{
//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);
}

私有函数事件。ioErrorHandler(事件:IOErrorEvent):无效
{
跟踪('事件。ioErrorHandler事件');
}

私有函数在completeHandler(事件:事件):无效
{
跟踪(在completeHandler事件');
}
 

解决方案

一种可能性,你可以考虑正在转换你的Loader来使用URLLoader,可以给你更多的灵活性上看到的数据实际上被请求/接收。

该display.Loader类有一些奇怪的怪癖,根本不会允许某些事件,如果它试图加载没有一个合适的入门级(通常display.Sprite派生的类)的对象火。

我想的URLLoader将是有益的,因为你可以设置URLLoaderDataFormat为二进制。这将捕获任何返回,并将其存储在一个ByteArray对象,你可以加载到通过Loader.loadBytes()一个display.Loader,如果它是一个有效的图像,或者干脆转换URLLoaderData.toString()来检索你的XML信息。

I am working with a loader to request an image from a WMS(Web Mapping Service). Everything thing is fine and dandy with a valid request.

When a bad request is made to a WMS, a Standard Exception Document(XML) is usually returned. However, the loader doesn't fire any event (specifically the Complete or IOError events) when a bad request is made.

Does anyone have any suggestions on how I can trap anything that is not an image that might be returned?

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');
}

解决方案

One possibility you could look into is converting your Loader to a URLLoader, as to give you more flexibility over seeing what data is actually being requested/received.

The display.Loader class has some strange quirks that simply won't allow certain events to fire if it attempts to load an object that does not have a proper entry class (typically a class derived from display.Sprite).

I think the URLLoader will be beneficial, as you can set the URLLoaderDataFormat to BINARY. This will catch whatever is returned and store it in a ByteArray object, which you can either load into a display.Loader via Loader.loadBytes() if it is a valid image, or simply convert the URLLoaderData.toString() to retrieve your XML information.

这篇关于故障使用ActionScript装载机活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆