home *** CD-ROM | disk | FTP | other *** search
- class com.rightactionscript.fcb.components.Loader extends com.rightactionscript.fcb.components.UIBasicComponent
- {
- var _bAutoLoad;
- var _bScaleContent;
- var _sURL;
- var _nBytesLoaded;
- var _nBytesTotal;
- var _mcHolder;
- var _bInited;
- var __width;
- var __height;
- var _bLoading;
- var _sPrevURL;
- var _mcFrame;
- var _mcMask;
- var _nPrevLoaded;
- var _nInterval;
- var dispatchEvent;
- var _bDoFade = false;
- var _bDrawFrame = false;
- var _oDimensions = null;
- var _nRoundCorners = 0;
- var _bLoaded = false;
- function Loader()
- {
- super();
- this._bAutoLoad = true;
- }
- function set scaleContent(bScaleContent)
- {
- this._bScaleContent = bScaleContent;
- }
- function get scaleContent()
- {
- return this._bScaleContent;
- }
- function set autoLoad(bAutoLoad)
- {
- this._bAutoLoad = bAutoLoad;
- }
- function get autoLoad()
- {
- return this._bAutoLoad;
- }
- function set contentPath(sURL)
- {
- this._sURL = sURL;
- if(this._bAutoLoad)
- {
- this.load();
- }
- }
- function get bytesLoaded()
- {
- return this._nBytesLoaded;
- }
- function get bytesTotal()
- {
- return this._nBytesTotal;
- }
- function get percentLoaded()
- {
- var _loc2_ = Math.round(this.bytesLoaded / this.bytesTotal * 100);
- _loc2_ = !isNaN(_loc2_) ? _loc2_ : 0;
- return _loc2_;
- }
- function get content()
- {
- return this._mcHolder.mcContent;
- }
- function init()
- {
- super.init();
- if(this._bScaleContent == undefined)
- {
- this._bScaleContent = true;
- }
- this._bInited = true;
- this._nBytesLoaded = 0;
- this._nBytesTotal = 0;
- }
- function createChildren()
- {
- this.createEmptyMovieClip("_mcHolder",this.getNextHighestDepth());
- this.createEmptyMovieClip("_mcFrame",this.getNextHighestDepth());
- this.createEmptyMovieClip("_mcMask",this.getNextHighestDepth());
- if(this._bAutoLoad && this._sURL != undefined)
- {
- this.load();
- }
- }
- function size()
- {
- this._xscale = 100;
- this._yscale = 100;
- if(this._bScaleContent)
- {
- var _loc5_ = this._mcHolder.mcContent._width;
- var _loc4_ = this._mcHolder.mcContent._height;
- var _loc2_ = _loc5_ / _loc4_;
- var _loc3_ = this.__width / this.__height;
- if(_loc2_ == _loc3_)
- {
- this._mcHolder._width = this.__width;
- this._mcHolder._height = this.__height;
- }
- else if(_loc2_ > _loc3_)
- {
- this._mcHolder._width = this.__width;
- this._mcHolder._height = this.__width / _loc2_;
- }
- else
- {
- this._mcHolder._width = this.__height * _loc2_;
- this._mcHolder._height = this.__height;
- }
- }
- else if(this._mcHolder.mcContent._width != undefined)
- {
- this._mcHolder._width = this._mcHolder.mcContent._width;
- this._mcHolder._height = this._mcHolder.mcContent._height;
- }
- }
- function load()
- {
- if(this._bLoading && this._sPrevURL == this._sURL || this._sURL == undefined || this._sURL == "" || this._mcHolder == undefined)
- {
- return undefined;
- }
- this._visible = false;
- this._bLoaded = false;
- this._bLoading = true;
- this._sPrevURL = this._sURL;
- this._mcHolder.mcContent.removeMovieClip();
- this._mcFrame.clear();
- this._mcMask.clear();
- this._mcHolder.attachMovie(this._sURL,"mcContent",1);
- if(this._mcHolder.mcContent == undefined)
- {
- this._mcHolder.mcContent.removeMovieClip();
- this._mcHolder.createEmptyMovieClip("mcContent",1);
- this._mcHolder.mcContent.loadMovie(this._sURL);
- this._nPrevLoaded = 0;
- this._nInterval = setInterval(this,"checkLoadProgress",50);
- }
- else
- {
- this.onLoadInit();
- }
- }
- function onLoadProgress(mc, bl, bt)
- {
- this._nBytesLoaded = bl;
- this._nBytesTotal = bt;
- this.dispatchEvent({type:"progress",target:this});
- }
- function onLoadInit()
- {
- this._bLoaded = true;
- this._bLoading = false;
- this.size();
- this._visible = true;
- this.dispatchEvent({type:"complete",target:this});
- }
- function checkLoadProgress()
- {
- var _loc2_ = this._mcHolder.mcContent.getBytesLoaded();
- var _loc3_ = this._mcHolder.mcContent.getBytesTotal();
- if(_loc2_ > this._nPrevLoaded)
- {
- this.onLoadProgress(this._mcHolder.mcContent,_loc2_,_loc3_);
- this._nPrevLoaded = _loc2_;
- }
- if(_loc2_ / _loc3_ == 1 && this._mcHolder.mcContent._width != 0)
- {
- this.onLoadInit();
- clearInterval(this._nInterval);
- }
- }
- function get loaded()
- {
- return this._bLoaded;
- }
- function set dimensions(oDimensions)
- {
- this._oDimensions = oDimensions;
- }
- function set drawFrame(bDrawFrame)
- {
- this._bDrawFrame = bDrawFrame;
- }
- function set doFade(bDoFade)
- {
- this._bDoFade = bDoFade;
- }
- function set roundcorners(nRoundCorners)
- {
- this._nRoundCorners = nRoundCorners;
- }
- }
-