03.05.2013 Views

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

}<br />

}<br />

try {<br />

checkEmail("Joe Smith");<br />

}<br />

catch (e) {<br />

this.createTextField("error_txt", this.getNextHighestDepth(), 0, 0, 100,<br />

22);<br />

error_txt.autoSize = true;<br />

error_txt.text = e.toString();<br />

}<br />

See also<br />

Error<br />

try..catch..finally statement<br />

try {<br />

// ... try block ...<br />

} finally {<br />

// ... finally block ...<br />

}<br />

try {<br />

// ... try block ...<br />

} catch(error [:ErrorType1]) {<br />

// ... catch block ...<br />

} [catch(error[:ErrorTypeN]) {<br />

// ... catch block ...<br />

}] [finally {<br />

// ... finally block ...<br />

}]<br />

Encloses a block of code in which an error can occur, <strong>and</strong> then respond to the error. If any<br />

code in the try code block throws an error (using the throw statement), control passes to the<br />

catch block, if one exists, <strong>and</strong> then to the finally code block, if one exists. The finally<br />

block is always executed, regardless of whether an error was thrown. If code in the try block<br />

doesn't throw an error (that is, if the try block completes normally), then the code in the<br />

finally block is still executed. The finally block is executed even if the try block exits<br />

using a return statement.<br />

A try block must be followed by a catch block, a finally block, or both. A single try block<br />

can have multiple catch blocks but only one finally block. You can nest try blocks as<br />

many levels deep as necessary.<br />

Statements 235

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!