You can extend one of the standard Error
classes to create your own specialized error classes in ActionScript.
There are a number of reasons to create your own error classes:
To identify specific errors or groups of errors that
are unique to your application.
For example, take different
actions for errors thrown by your own code, in addition to those
errors trapped by a Flash runtime. You can create a subclass of
the Error class to track the new error data type in
To provide unique error display capabilities for errors generated
by your application.
For example, you can create a new
that formats your error messages in a certain way. You can also
method that takes
an error code and retrieves the proper message based on the user’s
A specialized error class must extend the core ActionScript Error
class. Here is an example of a specialized AppError class that extends
the Error class:
public class AppError extends Error
public function AppError(message:String, errorID:int)
The following shows an example of using AppError in your project:
throw new AppError("Encountered Custom AppError", 29);
trace(error.errorID + ": " + error.message)
If you want to override the
in your subclass, give it one
The ECMAScript language specification on which ActionScript 3.0
is based defines the
way, and ActionScript 3.0 defines it the same way for backward compatibility.
Therefore, when you override the
match the parameters exactly. You do not want to pass any parameters
method at runtime, because those
parameters are ignored.