message (Error.message property)
public message : String
Contains the message associated with the Error object. By default, the value of this property is
"
". You can specify a
Error
error string to the
Error
Availability: ActionScript 1.0; Flash Player 7
Example
In the following example, a function throws a specified message depending on the parameters
entered into
. If two numbers can be divided,
theNum
Specific errors are shown if you try to divide by 0 or enter only 1 parameter:
function divideNum(num1:Number, num2:Number):Number {
if (isNaN(num1) || isNaN(num2)) {
throw new Error("divideNum function requires two numeric parameters.");
} else if (num2 == 0) {
throw new Error("cannot divide by zero.");
}
return num1/num2;
}
try {
var theNum:Number = divideNum(1, 0);
trace("SUCCESS! "+theNum);
} catch (e_err:Error) {
trace("ERROR! "+e_err.message);
trace("\t"+e_err.name);
}
If you test this ActionScript without any modifications to the numbers you divide, you see an
error displayed in the Output panel because you are trying to divide by 0.
See also
,
throw statement
try..catch..finally statement
name (Error.name property)
public name : String
Contains the name of the Error object. By default, the value of this property is "
Availability: ActionScript 1.0; Flash Player 7
property when you create an Error object by passing the
message
constructor function.
and the number are shown.
SUCCESS
".
Error
Error
547
Need help?
Do you have a question about the FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE and is the answer not in the manual?