Try..catch..finally Statement - MACROMEDIA FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE Reference

Flash lite 2.x actionscript language reference
Hide thumbs Also See for FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE:
Table of Contents

Advertisement

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 ... }]
Enclose a block of code in which an error can occur, and then respond to the error. If any code
within the
code block throws an error (using the
try
block, if one exists, and then to the
catch
block always executes, regardless of whether an error was thrown. If code within the
doesn't throw an error (that is, if the
block is still executed. The
finally
a
statement.
return
A
block must be followed by a
try
can have multiple
catch
many levels deep as desired.
The
parameter specified in a
error
or
. The variable in a
theException
x
multiple
blocks, typed errors let you catch multiple types of errors thrown from a single
catch
block.
try
finally
block completes normally), then the code in the
try
block executes even if the
finally
block, a
catch
blocks but only one
finally
handler must be a simple identifier such as
catch
handler can also be typed. When used with
catch
statement), control passes to the
throw
code block, if one exists. The
block, or both. A single
finally
block. You can nest
finally
block
try
block exits using
try
block
try
blocks as
try
or
e
Statements
217

Advertisement

Table of Contents
loading

Table of Contents