Add IOErrorEvent, HTTPStatusEvent, SecurityErrorEvent and Event.COMPLETE to URLLoader : URLLoader « Network « Flash / Flex / ActionScript






Add IOErrorEvent, HTTPStatusEvent, SecurityErrorEvent and Event.COMPLETE to URLLoader

 
package {
  import flash.events.*;
  import flash.net.*;

  import flash.display.*;
  public class Main extends Sprite{

    public function Main(  ) {
      var loader:URLLoader = new URLLoader(  );

      loader.addEventListener( IOErrorEvent.IO_ERROR, handleIOError );
      loader.addEventListener( HTTPStatusEvent.HTTP_STATUS, handleHttpStatus );
      loader.addEventListener( SecurityErrorEvent.SECURITY_ERROR, handleSecurityError );
      loader.addEventListener( Event.COMPLETE, handleComplete );

     // loader.dataFormat = DataFormat.VARIABLES;

      loader.load( new URLRequest( "example.txt" ) );
    }

    function handleIOError( event:IOErrorEvent ):void {
      trace( "Load failed: IO error: " + event.text ); 
    }

    function handleHttpStatus( event:HTTPStatusEvent ):void {
      trace( "Load failed: HTTP Status = " + event.status );
    }

    function handleSecurityError( event:SecurityErrorEvent ):void {
      trace( "Load failed: Security Error: " + event.text );
    }

    function handleComplete( event:Event ):void {
      trace( "The data has successfully loaded" );
    }
}}

        








Related examples in the same category

1.Loading XML
2.Loading Images
3.Trace loader data
4.Listen to the URLLoader complete event
5.Loading a Block of Text (Including HTML and XML)
6.Checking Load Progress
7.Understanding Flash Player Security
8.Load a picture
9.Display LoadBar
10.Load an XML file
11.Events and Event Handling for URLLoader
12.Event Listener Registration Examples
13.Accessing the Target Object
14.URLLoader Complete event
15.Accessing the Object That Registered the Listener