//!-- UTF8
import mx.events.EventDispatcher;
/**
* Wrapper class for MovieClipLoader.
* @author Johannes Axner <contact@johannesaxner.com>
*/
class com.johannesaxner.util.SWFLoader {
/**
* Vars and functions inherited by EventDispatcher.
*/
var dispatchEvent:Function;
var addEventListener:Function;
var removeEventListener:Function;
/**
* Class constructor
*/
function SWFLoader()
{
EventDispatcher.initialize(this);
}
/**
* Loads an external .SWF to a specified MovieClip.
*
* @param movieClip_mc Target MovieClip into which the .swf will load
* @param swf_str Filename of .swf file to load.
* @return The loaded MovieClip.
*/
function loadClip( movieClip_mc:MovieClip, swf_str:String ):MovieClip
{
var loader = new MovieClipLoader();
loader.addListener( this );
loader.loadClip( swf_str, movieClip_mc );
return movieClip_mc;
}
/**
* Listener; invoked when a call to loadClip() has successfully begun to download a file.
*
* @param target_mc Target MovieClip
*/
function onLoadStart( target_mc:MovieClip ):Void
{
var event_obj:Object = { target:target_mc, type: "onLoadStart" };
this.dispatchEvent( event_obj );
}
/**
* Listener; invoked when a file loaded with loadClip() has failed to load.
*
* @param target_mc MovieClip loaded by the loader.
* @param errorCode_str A string that explains the reason for the failure.
* @return One of two strings: "URLNotFound" or "LoadNeverCompleted".
*/
function onLoadError ( target_mc:MovieClip, errorCode_str:String ):String
{
var event_obj:Object = { target:target_mc, type:"onLoadError", code: errorCode_str };
this.dispatchEvent( event_obj );
return errorCode_str;
};
/**
* Listener; invoked every time the loading content is written to disk during the loading process.
*
* @param target_mc MovieClip loaded by the loader.
* @param bytesLoaded
* @param bytesTotal
*/
function onLoadProgress( target_mc:MovieClip, bytesLoaded:Number, bytesTotal:Number ):Void
{
var event_obj:Object = { target:target_mc, type:"onLoadProgress", bytesLoaded:bytesLoaded, bytesTotal:bytesTotal };
this.dispatchEvent( event_obj );
};
/**
* Listener; invoked when a file loaded with loadClip() has completely downloaded.
*
* @param target_mc MovieClip loaded by the loader.
*/
function onLoadComplete( target_mc:MovieClip ):Void
{
var event_obj:Object = { target:target_mc, type:"onLoadComplete" };
this.dispatchEvent( event_obj );
};
/**
* Listener; invoked when the actions on the first frame of the loaded clip have been executed.
*
* @param target_mc MovieClip loaded by the loader.
*/
function onLoadInit( target_mc:MovieClip ):Void
{
var event_obj:Object = { target:target_mc , type: "onLoadInit" };
this.dispatchEvent( event_obj );
};
}