Try..catch..finally Statement - MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE Reference

Actionscript 2.0 language reference
Table of Contents

Advertisement

try {
checkEmail("Joe Smith");
}
catch (e) {
error_txt.text = e.toString();
}
In the following example, a subclass of the Error class is thrown. The
is modified to throw an instance of that subclass.
// Define Error subclass InvalidEmailError // In InvalidEmailError.as:
class InvalidEmailAddress extends Error { var message = "Invalid email
address."; }
In a FLA or AS file, enter the following ActionScript in Frame 1 of the Timeline:
import InvalidEmailAddress;
function checkEmail(email:String) {
if (email.indexOf("@") == -1) {
throw new InvalidEmailAddress();
}
}
try {
checkEmail("Joe Smith");
}
catch (e) {
this.createTextField("error_txt", this.getNextHighestDepth(), 0, 0, 100,
22);
error_txt.autoSize = true;
error_txt.text = e.toString();
}
See also
Error

try..catch..finally statement

try {
// ... try block ...
} finally {
// ... finally block ...
}
try {
// ... try block ...
} catch(error [:ErrorType1]) {
// ... catch block ...
} [catch(error[:ErrorTypeN]) {
// ... catch block ...
}] [finally {
// ... finally block ...
230
ActionScript language elements
function
checkEmail()

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

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

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash 8

Table of Contents

Save PDF