This post is in response to Nate, who asked me this question a few days ago.
If you load a file using AS3, there are a couple of potential outcomes –
- The file exists, you have permissions to access it, and it completes successfully! Hurray! The
URLLoaderdispatches anEvent.COMPLETE. - The file exists, but you don’t have permissions – the
URLLoaderdispatches aSecurityErrorEvent.SECURITY_ERROR. - The file doesn’t exist, or you otherwise can’t access it – the
URLLoaderdispatches anIOErrorEvent.IO_ERROR.
Flash is an incredibly event driven framework. Everything seems to dispatch an event or five. Most of these events you simply ignore, because nobody really needs this level of information. This leads to a tricky situation, however, when the default event behavior (just ignore it) doesn’t work.
Specifically, ErrorEvents and their subclasses, if not listened for by something, will pop up an error dialog to the user. So, in the case when you’re loading a file, but you don’t really care if it exists or not, you actually have to listen for IO and security error events, and explicitly ignore them, for the usually-default event behavior to work.
More generally, there are two sets of event behaviors an AS3 developer needs to know:
ErrorEvents (and subclasses) must be listened for if they’re to be ignored, otherwise the user gets a error box.Events (and non-ErrorEventsubclasses) can be ignored without repercussion.
Yeah I thought try catch would have done it, but that’s only good for synchronous events. Thanks for the help bud! :-)
s1fnndbzpznzus6n