Are ActionScript 3 errors used in the same way as Java exceptions?

My first guess: NO. An exception in Java is here to catch the “expected” exceptions and handle them in the application. Error in ActionScript 3 to handle "unexpected" errors. I'm right?

+4
source share
3 answers

Exceptions in ActionScript and Java have the same concept, except for the following:

  • Java checks and throws exceptions. In ActionScript, all exceptions are not marked, so you need to read the API documentation or source code to handle possible exceptions that a particular method may throw. All ActionScript exceptions that can be thrown are inherited from the Error class.
  • ActionScript in Flash Player is asynchronous. It is for this reason that you cannot handle some exceptions with the try…catch…finally . 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 that have the same function as exceptions. They inherit from flash.events.ErrorEvent and throw exceptions if there are no corresponding event listeners. For example, SWFLoader can trigger an ioError type flash.events.IOErrorEvent , which must be processed.

Everything related to bugs seems to be Java :)

+8
source

Yes. Although errors in Java relate to issues outside the scope of the ordinary programmer, errors in ActionScript are handled in try ... catch ... finally, for example Exceptions in Java.

See the ActionScript 2 manual and Adobe documentation .

0
source

No. Not this way.

this is the syntax

 try { // statements } catch (error:ArgumentError) { trace('An argument error has occured'); } catch (error:Error) { trace('An error has occured which is not argument related'); } 

we can use reasoned exceptions, such as IO, custom events.

0
source

All Articles