Error constructor
public Error([message:String])
Creates a new Error object. If
property.
Error.message
Availability: ActionScript 1.0; Flash Lite 2.0
Parameters
[optional] - A string associated with the Error object.
message:String
Example
In the following example, a function throws an error (with a specified message) if the two
strings that are passed to it are not identical:
function compareStrings(str1_str:String, str2_str:String):Void {
if (str1_str != str2_str) {
throw new Error("Strings do not match.");
}
}
try {
compareStrings("Dog", "dog");
// output: Strings do not match.
} catch (e_err:Error) {
trace(e_err.toString());
}
See also
,
throw statement
try..catch..finally statement
message (Error.message property)
public message :
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 Lite 2.0
is specified, its value is assigned to the objects
message
String
property when you create an Error object by passing the
message
constructor function.
Error
359