Jump to content
Search Community

Is there a way to trap XMLLoader ioError?

cerulean test
Moderator Tag

Recommended Posts

I'm trying to check for the existence of an XML file — I'm doing this by doing a bogus load and returning the value of success or failure, thus:

	public static function RFIDExists($func:Function):void {
			var filename:String = RFID_READ_FILE;
			TTUtils.trc(7,"RFIDExists $func", $func);
			var loader:XMLLoader = new XMLLoader(SERVER_PATH + filename, {onComplete:function() {$func(true)},onIOError:function() {$func(false)}});
		
				loader.load();
		}

Where $func is a function that will be called and take action based on the result.  It works perfectly.

 

My question is that the IDE keeps reporting errors such as 

Error on XMLLoader 'loader9' (http://localhost/tt/xml/scan.xml): Error #2032: Stream Error. URL: http://localhost/tt/xml/scan.xml

Which is understandable, of course, but I don't want the program to 'crash' because I'm trying to load a file that isn't there.  Is there a way to 'trap' this error so that it basically disappears?  Is there another way (outside of AIR) to check for a file existence than this?

Link to comment
Share on other sites

It sounds like you're just talking about the trace() statements. Those are intended to help you debug things, but they don't halt execution at all and they're typically only visible in the IDE anyway. It isn't as though people seeing your swf at runtime would ever see that stuff, and it wouldn't cause failures. You can simply select the "omit trace statements" option in the publish settings if you want those omitted. Or I suppose you could delete the trace() in the source code. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...