home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mobiclic 161
/
MOBICLIC161.ISO
/
pc
/
Milan.swf
/
scripts
/
com
/
milanpresse
/
capsule
/
LoadLib.as
< prev
Wrap
Text File
|
2014-01-15
|
4KB
|
128 lines
package com.milanpresse.capsule
{
import flash.display.Loader;
import flash.events.Event;
import flash.events.HTTPStatusEvent;
import flash.events.IEventDispatcher;
import flash.events.IOErrorEvent;
import flash.events.ProgressEvent;
import flash.net.URLRequest;
import flash.system.ApplicationDomain;
import flash.system.LoaderContext;
public class LoadLib
{
private var _swfPath:String = null;
private var _classPath:String = null;
private var _callback:Function = null;
private var _loader:Loader;
private var _lib = null;
private var _params:Object = null;
public function LoadLib(param1:String = null, param2:String = null, param3:Function = null, param4:Object = null)
{
super();
this._params = param4;
this._swfPath = param2;
this._classPath = param1;
this._callback = param3;
this.init();
}
private function init() : void
{
if(this._classPath == null || ApplicationDomain.currentDomain.hasDefinition(this._classPath) == false)
{
this.loadLib(this._swfPath);
}
else
{
this.libLoaded();
}
}
private function libLoaded() : void
{
this.libInitialised();
}
private function libInitialised() : void
{
if(this._callback != null)
{
this._callback();
}
}
private function loadLib(param1:String) : void
{
this._loader = new Loader();
this.loaderAddListeners(this._loader.contentLoaderInfo);
this._loader.load(new URLRequest(param1),new LoaderContext(false,ApplicationDomain.currentDomain));
}
private function loaderAddListeners(param1:IEventDispatcher) : void
{
param1.addEventListener(Event.COMPLETE,this.completeHandler);
param1.addEventListener(HTTPStatusEvent.HTTP_STATUS,this.httpStatusHandler);
param1.addEventListener(Event.INIT,this.initHandler);
param1.addEventListener(IOErrorEvent.IO_ERROR,this.ioErrorHandler);
param1.addEventListener(Event.OPEN,this.openHandler);
param1.addEventListener(ProgressEvent.PROGRESS,this.progressHandler);
param1.addEventListener(Event.UNLOAD,this.unLoadHandler);
}
private function loaderRemoveListeners(param1:IEventDispatcher) : void
{
param1.removeEventListener(Event.COMPLETE,this.completeHandler);
param1.removeEventListener(HTTPStatusEvent.HTTP_STATUS,this.httpStatusHandler);
param1.removeEventListener(Event.INIT,this.initHandler);
param1.removeEventListener(IOErrorEvent.IO_ERROR,this.ioErrorHandler);
param1.removeEventListener(Event.OPEN,this.openHandler);
param1.removeEventListener(ProgressEvent.PROGRESS,this.progressHandler);
param1.removeEventListener(Event.UNLOAD,this.unLoadHandler);
}
private function completeHandler(param1:Event) : void
{
this.loaderRemoveListeners(this._loader.contentLoaderInfo);
this.libLoaded();
}
private function httpStatusHandler(param1:HTTPStatusEvent) : void
{
}
private function initHandler(param1:Event) : void
{
}
private function ioErrorHandler(param1:IOErrorEvent) : void
{
}
private function openHandler(param1:Event) : void
{
}
private function progressHandler(param1:ProgressEvent) : void
{
}
private function unLoadHandler(param1:Event) : void
{
}
public function destroy() : void
{
}
}
}