Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are ActionScript 3 Errors used the same way Java Exceptions are ?

My first guess is: NO. Exception in Java are here to catch 'expected' exceptions and handle them within the application. Error in ActionScript 3 are here to handle 'unexpected' errors. Am I right ?

like image 911
Ced Avatar asked Feb 24 '23 06:02

Ced


1 Answers

Exceptions in ActionScript and Java have the same conception except the following:

  • Java has checked and unchecked exceptions. In ActionScript all the exceptions are unchecked, so you need to read API documentation or source code to handle possible exceptions which a particular method can throw. All the ActionScript exceptions which can be thrown are inherited from the Error class.
  • ActionScript in Flash Player has an asynchronous nature. This is the reason you can't handle some exceptions with a try…catch…finally block. Prior to Flash Player 10.1 there was no way to handle these exceptions. Flash Player 10.1 added global error handling with flash.events.UncaughtErrorEvent.
  • Some classes produce documented error events which have the same function as exceptions. They are inherited from flash.events.ErrorEvent and produce exceptions in case of absence of corresponding event listeners. For example, SWFLoader can fire ioError of type flash.events.IOErrorEvent which should be handled.

All the other things related to errors are similar to Java :)

like image 134
Constantiner Avatar answered Apr 07 '23 09:04

Constantiner