<Catch Errors in ActionScript 3.0/>
Posted by Gaurav Jassal | on 09/26 at 09:53 AM | Actionscript 3.0 • Daily Digest • Flash 8 • Flex 3 •
Errors
One thing you may notice about ActionScript 3 how error prone it is or, rather, how error prone it perceives you to be. You’ll see a lot more errors, not only during compile, but also runtime. ActionScript 3 is much less lenient in letting you get away with mistakes or code conflicts. Whereas ActionScript 1 and 2 may silently fail or ignore many errors, ActionScript 3 will be sure to let you know something went wrong.
Synchronous Errors
Normal errors in code which occur as a code block is being executed are synchronous errors. When the Flash player encounters one of these errors in code, an error, or exception, is thrown. At that point the Flash player will suspend all code in the current block and prevent it from continuing unless the exception is taken care of or caught. To catch exceptions in ActionScript, you use a try..catch..finally statement.
The try..catch..finally statement lets you try a block of code possible of throwing an error and react accordingly if an error occurs. It consists of 2 or more blocks of code: an initial try block, consisting of the code that could throw an error, 1 or more catch blocks that catch errors of different types and run if that type of error is thrown, and an optional finally block which is run after the try and any catches whether or not an error occurs. Its format is as follows:
<read complete article/>









