Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

event listener for flex/air action script errors

I'm trying to add an event listener to my air application that would prevent the "ActionScript error" window from appearing, so I can handle the error within my application.

I was able to find a little information about this from adobe. I'm just not sure what I should be listening for.

like image 600
Adam Avatar asked Jul 14 '26 09:07

Adam


1 Answers

It depends quite a lot on what error is thrown, and why.

Your best bet is to carefully read the ActionScript documentation and add listeners to react to all of the errors that have explicit ErrorEvents (such as IOErrorEvent and SecurityErrorEvent). Those are usually related to network and/or file access, and security issues.

For most other errors, there is the try {} catch() {} finally {} statements. This tutorial might be a good place to start.

And if all else fails, there's UncaughtErrorEvent.

But you should really be using that one as a last resort, not as a magic bullet - the best error handling is a) trying to prevent errors from being thrown in the first place (make sure all variables are properly initialized, test for null, etc.), and b) handling expected runtime errors by catching them explicitly, in order to keep the application running and stable.

like image 186
weltraumpirat Avatar answered Jul 17 '26 16:07

weltraumpirat