throw Error in a function : throw « Statement « Flash / Flex / ActionScript






throw Error in a function

 

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


        var sUsername:String = tUsername.text; 
        
        try {
          checkUsername(sUsername);
        }
        catch (erObject:Error) {
          trace("An error was thrown.");
        }
    }
    function checkUsername(sUsernameParam:String) {
      if(sUsernameParam == "") {
        throw new Error();
      }
    } 
  }
}

        








Related examples in the same category

1.Rethrowing Exceptions