MACROMEDIA FLEX-FLEX ACTIONSCRIPT LANGUAGE Reference page 288

Actionscript language reference
Table of Contents

Advertisement

throw new Error("Strings to not match.");
}
}
try {
compareStrings("Dog", "dog");
// output: Strings to not match.
} catch (e_err:Error) {
trace(e_err.toString());
}
See also
throw,
try..catch..finally
Error.message
Availability
Flash Player 7.
Usage
my_err.message:String
Description
Property; contains the message associated with the Error object. By default, the value of this
property is "
Error
passing the error string to the
Example
In the following example, a function throws a specified message depending on the parameters
entered into
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
try..catch..finally
288
Chapter 6: ActionScript Core Classes
". You can specify a
message
constructor function.
Error
. If two numbers can be divided,
property when you create an Error object by
and the number are shown.
SUCCESS

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLEX-FLEX ACTIONSCRIPT LANGUAGE and is the answer not in the manual?

This manual is also suitable for:

Flex

Table of Contents