Catching Errors Generated by Flash : Try catch : Statement Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » Statement » Try catch »

 

Catching Errors Generated by Flash


 

package{
  import flash.display.*;
  
  public class Main extends Sprite{
    public function Main(){

        var object:Object = "Definitely Not a Display Object";
        try
        {
            var displayObject:DisplayObject = DisplayObject(object);
        catch (error:TypeError) {
            trace("Incompatible cast!");
            displayObject = new Sprite();
        }
        addChild(displayObject);

    }
  }
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo Statement
» Try catch