RSS
email

Handling Errors in Actionscript 3 | Flash CS5 try catch in Flash Player



Flash Player 8.5 supports a try/catch methodology for handling errors in ActionScript. That means you can write code that can intelligently deal with certain error types should they occur. While you cannot handle syntax errors (the .swf won't even compile in that case), you can handle most other error types, such as missing or invalid data. The benefit is that you can attempt to resolve the situation programmatically.

Use a throw statement to throw an error when it is detected. Place any potentially error-generating code within a try block, and then have one or more corresponding catch blocks to handle possible errors.

An example situation:

Suppose we are creating an email application in flash actionscript 3.0 using smtp. We have


  1. To
  2. Subject
  3. messase box


We need the above three as input from user, the first input "To" to whom we are going to mail is mandatory list. so if user forgot to type any mail id or if the typed mail id is not valid then we need to throw an error and exception, must handle error in actionscript.

There are two basic parts involved in working with errors in ActionScript: throwing the error and catching the error. There are several errors, which are thrown automatically by the player, such as IllegalOperationError, MemoryError, and ScriptTimeoutError.

For more of Handling error in actionscript

Bookmark and Share

0 comments:

 

Recent Posts

Recent Visitors

Donate Me

About Me

My photo
Chennai, Tamil nadu, India
Nothing more to say about me.. Just a Action Script programmer / Flex developer having 4.5 years of experience.