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