Add event listener to content loader info
package {
import flash.display.*;
import flash.text.*;
import flash.net.URLRequest;
import flash.events.*;
public class Main extends Sprite {
public function Main( ) {
var loader:Loader = new Loader( );
addChild( loader );
loader.contentLoaderInfo.addEventListener( Event.OPEN, handleOpen );
loader.contentLoaderInfo.addEventListener( ProgressEvent.PROGRESS, handleProgress );
loader.contentLoaderInfo.addEventListener( Event.COMPLETE, handleComplete );
loader.load( new URLRequest( "image.jpg" ) );
}
private function handleOpen( event:Event ):void {
trace( "open" );
}
private function handleProgress( event:ProgressEvent ):void {
var percent:Number = event.bytesLoaded / event.bytesTotal * 100;
trace( "progress, percent = " + percent );
}
private function handleComplete( event:Event ):void {
trace( "complete" );
}
}
}
Related examples in the same category