Flash Player 7.
throw expression
Action; generates ("throws") an error that can be handled ("caught") by a catch code block. If an exception is not caught by a catch statement, the string representation of the thrown value is sent to the Output window.
expression An ActionScript expression or object.
In this example...
function GetSquareRoot(Number:val) {
try {
// Calculate the square root of the val parameter
if (val < 0 || isNaN(val) || !isFinite(val)) {
throw new SquareRootException();
}
return Math.sqrt(val);
} catch (e) {
// Display error message
if(e instanceof SquareRootException) {
trace("Square root failed; number may be out of range.");
} else {
trace("An unknown error occurred")
}
}
function SquareRootException()
{
}