Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Types of Errors in ActionScript

    • 0
    • 2
    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 668
    Comment on it

    The error is any mistake that we make while writing a program which hampers the proper functioning of the program. While creating and running any application we encounter different types of errors. An error produces undesired output or other behavior , although it may not be recognized immediately. So the different types of errors that we can come across in ActionScript are as follows:-

    • Compile-time error :- These are the errors which are recognized by the actionscript compiler during the runtime. The compile time errors are detected during the transition when program is converted into machine language.
    • Run-time errors :- These are the errors which occur after the compilation of the program i.e during the runtime. This kind of error happens when SWF (Small Web File) plays in Adobe Flash Player or Adobe AIR. For handling runtime errors we can use the error handling methods to allow the application to finish gracefully.
    • Synchronous errors :- Synchronous errors are the runtime errors that happen once the function is invoked or called. To tackle such errors we use the synchronous error handling logic i.e inserting statements in your code to keep a track of the errors. The below example is a sample block of code to handle such errors:


    try 
       { 
           // some code that could throw an error 
       } 
         catch (err:Error) 
      { 
          // code to react to the error 
      } 
        finally 
      { 
        // Code that runs whether or not an error was thrown. 
      }
    
    • Asynchronous errors :- These are the kind of errors that generate events and are caught by event listeners and these kind of errors occur at various points during the runtime. An asynchronous operation is that in which a function starts an operation, but doesnt waits for its completion. For that we need to create an error event listener to wait for the user to try some operation, and if the operation fails, then we can catch the error with an event listener and respond to the error event.
     var fileRef:FileReference = new FileReference(); 
       fileRef.addEventListener(Event.SELECT, selectHandler); 
       fileRef.addEventListener(Event.OPEN, openHandler); 
       fileRef.addEventListener(Event.COMPLETE, completeHandler); 
       fileRef.browse(); 
    
    function selectHandler(event:Event):void 
    { 
        trace("...select..."); 
        var request:URLRequest = new URLRequest("http://www.yourdomain.com/fileupload.cfm"); 
        request.method = URLRequestMethod.POST; 
        event.target.upload(request.url); 
    } 
    function openHandler(event:Event):void 
    { 
        trace("...open..."); 
    } 
    function completeHandler(event:Event):void 
    { 
        trace("...complete..."); 
    }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: