home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FCE Gold Plus
/
GOLD.iso
/
pc
/
shell.swf
/
scripts
/
__Packages
/
com
/
util
/
PreLoader.as
< prev
Wrap
Text File
|
2007-10-16
|
4KB
|
119 lines
class com.util.PreLoader extends com.event.observable
{
function PreLoader(_mcOwner)
{
var _loc1_ = this;
super();
_loc1_.mcLoaderChild = new MovieClip();
_loc1_.mcLoader = new MovieClip();
_loc1_.mcTargetDraw = _mcOwner;
}
function loadMovieClip(_mcTarget, _strText)
{
var _loc1_ = this;
_loc1_.objTarget = _mcTarget;
_loc1_.drawPreLoader(_strText);
_loc1_.mcTargetDraw.objRef = _loc1_;
_loc1_.mcTargetDraw.blnLoaded = false;
_loc1_.mcTargetDraw.onEnterFrame = function()
{
var _loc1_ = this;
if(_loc1_.blnLoaded == true)
{
trace(":::::");
_loc1_.blnLoaded = false;
delete _loc1_.onEnterFrame;
_loc1_.objRef.destroyPreLoader();
_loc1_.objRef.broadcastEvent("PreloaderUpdate");
}
else
{
_loc1_.objRef.checkProgress();
}
};
}
function checkProgress()
{
this.updatePreLoader();
}
function loadXML(_objXML)
{
var _loc1_ = this;
_loc1_.objTarget = _objXML;
_loc1_.mcTargetDraw.objRef = _loc1_;
_loc1_.mcTargetDraw.blnLoaded = false;
_loc1_.mcTargetDraw.onEnterFrame = function()
{
var _loc1_ = this;
if(_loc1_.blnLoaded == true)
{
trace(":::::");
_loc1_.objRef.broadcastEvent("PreloaderUpdate");
_loc1_.objRef.destroyPreLoader();
delete _loc1_.onEnterFrame;
}
else
{
_loc1_.objRef.checkProgress();
}
};
}
function drawPreLoader(_strTxt)
{
this.mcLoader = this.mcTargetDraw.createEmptyMovieClip("mcLoadBar",1000000);
this.mcLoader._x = Stage.width / 2 - 50;
this.mcLoader._y = Stage.height / 2 - 5;
with(this.mcLoader)
{
beginFill(16777215,0);
lineStyle(1,13421772,100);
moveTo(0,0);
lineTo(100,0);
lineTo(100,6);
lineTo(0,6);
endFill();
}
this.mcLoaderChild = this.mcLoader.createEmptyMovieClip("mcLine",0);
with(this.mcLoaderChild)
{
beginFill(16711680);
moveTo(0,2);
lineTo(3,2);
lineTo(3,5);
lineTo(0,5);
endFill();
}
this.mcTextLoader = this.mcTargetDraw.createEmptyMovieClip("mcLoadBar",1000005);
this.mcTextLoader.createTextField("txt_percent",4,this.mcLoader._x,this.mcLoader._y + 10,200,100);
var objTF = new TextFormat();
objTF.bold = false;
objTF.font = "Verdana";
objTF.size = 9;
objTF.color = 13421772;
this.mcTextLoader.txt_percent.setNewTextFormat(objTF);
this.mcTextLoader.txt_percent.text = _strTxt;
}
function setPreLoaderParent(mcParent)
{
}
function updatePreLoader()
{
var _loc1_ = this;
_loc1_.mcLoaderChild._width = _loc1_.loadedPercent();
if(_loc1_.loadedPercent() >= 100 && _loc1_.objTarget.getBytesTotal() > 0)
{
_loc1_.mcLoaderChild._width = 100;
_loc1_.mcTargetDraw.blnLoaded = true;
}
}
function loadedPercent()
{
return Number(this.objTarget.getBytesLoaded() / this.objTarget.getBytesTotal() * 100);
}
function destroyPreLoader()
{
removeMovieClip(this.mcLoader);
removeMovieClip(this.mcTextLoader);
}
}