• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

The Error Object

Flash MX 2004 includes an Error object that makes it easy to set up traps for various conditions while your app runs. That is, it’s basically a glorified if statement that will trigger code if certain conditions are met. The reason I made this like an epilogue at the end of the chapter is that it’s really not a tool for debugging. It’s an error trap—equivalent to trapping an event. In addition, it only triggers at runtime (when your bugs should be well out of the way). In any event, I think it’s worth documenting here.

The benefit is that for several different places in your code, you may have the same condition you’re checking. Suppose, for instance, that you build a calculator. When the user attempts to divide by zero, you want to give the user some meaningful feedback instead of just displaying NaN (not a number). You can define an Error object that specifies off-limit conditions, what to do when those conditions occur, what do to do otherwise, and—optionally—what to do in all cases.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint