Catch Loader error

By whisher | Sep 27, 2009

actionscript3

Hi.
How can I catch errors from as3.
I tried this way but it doesn’t work
(if an url doesn’t exist I got
Error #2044 IOErrorEvent uncaught
Error #2035: Impossible find URL
)

ActionScript Code:
package w{     import flash.events.ErrorEvent;     import flash.events.IOErrorEvent;     import flash.display.Loader;     import flash.net.URLLoader;     import flash.net.URLRequest;     public class ContentDataLoader {         private var _loader:Loader;         private var _loaderContainer:LoaderContainer;/*It’s a simple mvc I’ve in the stage*/         public function ContentDataLoader(loaderContainer:LoaderContainer) {//trace(’pippo’);             _loaderContainer=loaderContainer;             _loader=new Loader();         }         public function load(contentData:String):void {             _loader.addEventListener(IOErrorEvent.IO_ERROR,onError);             _loader.load(new URLRequest(contentData));         }         private function onError(evt:ErrorEvent):void {             trace(“cannot load data file”);         }         public function get loaderContainer():LoaderContainer {             return _loaderContainer;         }         public function get loader():Loader {             return _loader;         }     } }

Can you help me, please ?

Thanks in advance.

Bye :)

actionscript3

Please reply at our Forum

1 Comment so far
  1. Andreas Renberg September 27, 2009 3:19 pm

    Just a little typo. Try this:

    private function onError(evt:IOErrorEvent):void {
    trace(“cannot load data file”);
    }

Leave a Comment

If you would like to make a comment, please fill out the form below.

Name (required)

Email (required)

Website

Comments

© 2007 ActionScript 3.0