flash - AS3错误#2044 : Unhandled error: whilst using URLLoader even with IOErrorEvent event listener

标签 flash actionscript-3 error-handling urlloader

我偶尔会出现Flash pop 错误:

错误#2044:未处理的错误:。文字=

我的代码在这里:

    private var _myLoader:URLLoader = new URLLoader();

    public function load():void {       
        var finalURL = http://xxxxx.com/service_staging.php/next;

        var myRequest:URLRequest = new URLRequest(finalURL);

        // add event listeners
        this._myLoader.addEventListener(Event.COMPLETE, this._completeHandler);
        this._myLoader.addEventListener(Event.OPEN, this._openHandler);
        this._myLoader.addEventListener(ProgressEvent.PROGRESS, this._progressHandler);
        this._myLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, this._securityErrorHandler);
        this._myLoader.addEventListener(HTTPStatusEvent.HTTP_STATUS, this._httpStatusHandler);
        this._myLoader.addEventListener(IOErrorEvent.IO_ERROR, _ioErrorHandler);

        try {
            this._myLoader.load(myRequest);
        } catch (_error:SecurityError) {
            Logger.error('JSONRequest.as - catch: A SecurityError has occurred:', _error);

        } catch(_error:IOErrorEvent) {
            Logger.error("JSONRequest.as - catch: IOErrorEvent:", _error);      

        } catch(_error:Error) {
            Logger.error("JSONRequest.as - catch: Error catch: ", _error);
        }
    }   

    //----------------------------------------------------------    

    private function _completeHandler(event:Event):void {           
        Logger.info('JSONRequest.as - _completeHandler()');


        Logger.info('this._myLoader.data', this._myLoader.data);

        // decode the object
        this._JSONObject = JSON.decode(this._myLoader.data);

        // dispatch the complete event
        this.dispatchEvent(new Event(Event.COMPLETE));
    }   

    //----------------------------------------------------------    

    private function _ioErrorHandler(_error:IOErrorEvent):void {
        Logger.error('JSONRequest.as - _ioErrorHandler()');

        dispatchEvent(new ErrorEvent(ErrorEvent.ERROR));
    }

    //----------------------------------------------------------

    private function _securityErrorHandler(_event:SecurityErrorEvent):void {
        Logger.info("JSONRequest.as - _securityErrorHandler(): ", _event);

        dispatchEvent(new ErrorEvent(ErrorEvent.ERROR));
    }

    //----------------------------------------------------------

    private function _openHandler(event:Event):void {
       Logger.info("JSONRequest.as - openHandler: " + event);
    }

    //----------------------------------------------------------

    private function _progressHandler(event:ProgressEvent):void {
        Logger.info("JSONRequest.as - progressHandler loaded:" + event.bytesLoaded + " total: " + event.bytesTotal);
    }

    //----------------------------------------------------------

    private function _httpStatusHandler(event:HTTPStatusEvent):void {
        Logger.info("JSONRequest.as - httpStatusHandler: " + event);
        Logger.info("status: " + event.status);
    }

    //----------------------------------------------------------

    public function get JSONObject():Object {
        return this._JSONObject;
    }

    //----------------------------------------------------------

我已经处理了从服务获取JSON数据时出现的问题,但是即使我正在侦听此错误仍然会 pop 。

任何想法将不胜感激。

谢谢。

最佳答案

您应该将这些侦听器添加到_myLoader.contentLoaderInfo

this._myLoader.contentLoaderInfo.addEventListener(Foo.BAR, onFooBar);

关于flash - AS3错误#2044 : Unhandled error: whilst using URLLoader even with IOErrorEvent event listener,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9298031/

相关文章:

c# - C# 上的 Flash 相似性

javascript - Facebook 应用程序中的图表

ActionScript 中的 JavaScript 警报

python - python-flask处理应用程序错误

asp.net-mvc - 在 ASP.NET MVC 3 中使用 Ajax 响应发送自定义错误页面

ios - Flash Air iOS 开发 : Is it possible to launch a browser from within your applications?

flash - 使用 ActionScript 3 在 Flash 中排列 (z) 对象的顺序?

actionscript-3 - 有没有一种方法可以从对象中删除未知事件监听器?

actionscript-3 - 优化2D Flash游戏的过渡/运动平滑度

javascript - HTML5 表单验证——错误信息自定义