72 lines
1.8 KiB
ActionScript
72 lines
1.8 KiB
ActionScript
package com.common
|
|
{
|
|
import flash.display.Loader;
|
|
import flash.display.MovieClip;
|
|
import flash.events.Event;
|
|
import flash.events.IOErrorEvent;
|
|
import flash.events.ProgressEvent;
|
|
import flash.net.URLRequest;
|
|
|
|
public class LoadResource
|
|
{
|
|
|
|
public var loader:Loader;
|
|
|
|
public var backFunc:Function;
|
|
|
|
public var progressMc:MovieClip;
|
|
|
|
public var viewLoad:Boolean;
|
|
|
|
public var url:String;
|
|
|
|
public function LoadResource(param1:String, param2:Function, param3:Boolean = false)
|
|
{
|
|
super();
|
|
this.url = param1;
|
|
this.viewLoad = this.viewLoad;
|
|
this.backFunc = param2;
|
|
LoadManage.getInstance().addNewLoad(this);
|
|
}
|
|
|
|
public function beginLoad() : void
|
|
{
|
|
this.loader = new Loader();
|
|
this.loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,this.loadError);
|
|
this.loader.contentLoaderInfo.addEventListener(Event.COMPLETE,this.loadComplete);
|
|
this.loader.load(new URLRequest(this.url));
|
|
}
|
|
|
|
private function loadError(param1:IOErrorEvent) : void
|
|
{
|
|
LoadManage.getInstance().reduceLoadCount();
|
|
}
|
|
|
|
private function loadProgress(param1:ProgressEvent) : void
|
|
{
|
|
}
|
|
|
|
private function loadComplete(param1:Event) : void
|
|
{
|
|
this.backFunc(param1);
|
|
LoadManage.getInstance().reduceLoadCount();
|
|
}
|
|
|
|
public function clear() : void
|
|
{
|
|
if(this.loader != null)
|
|
{
|
|
try
|
|
{
|
|
this.loader.unloadAndStop(true);
|
|
}
|
|
catch(error:Error)
|
|
{
|
|
}
|
|
this.loader = null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|