home *** CD-ROM | disk | FTP | other *** search
- function ProgressBarClass()
- {
- this.init();
- if(this.displayBar == undefined)
- {
- this.displayBar = true;
- this.kBTally = true;
- }
- this.maxV = 100;
- this.minV = 0;
- this.value = 0;
- this.oldValue = 0;
- this.width = this._xscale;
- this._xscale = this._yscale = 100;
- this.boundingBox_mc._visible = false;
- this.setChangeHandler(this.changeHandler);
- if(this.displayBar)
- {
- this.attachMovie("Track","track",0);
- }
- this.setDisplayText(this.kBTally);
- this.setSize(this.width);
- }
- Object.registerClass("FProgressBarSymbol",ProgressBarClass);
- ProgressBarClass.prototype = new FUIComponentClass();
- ProgressBarClass.prototype.setSize = function(w, h)
- {
- this.width = w;
- this.height = h;
- this.stretchToSize(w,this.track.leftTrack,this.track.midTrack,this.track.rightTrack);
- this.KBText._x = this.track._x;
- this.KBText._y = this.track._y + this.track._height + 0;
- this.KBText.setSize(w);
- this.renderBar();
- };
- ProgressBarClass.prototype.setLoadTarget = function(mcRef)
- {
- this.loadTarget = mcRef;
- this.createEmptyMovieClip("loadPoller",10);
- this.loadPoller.onEnterFrame = function()
- {
- var comp = this._parent.loadTarget;
- this._parent.setProgress(comp.getBytesLoaded(),comp.getBytesTotal());
- if(this._parent.getPercentComplete() >= 100 && this._parent.getValue() > 4)
- {
- delete this.onEnterFrame;
- }
- };
- };
- ProgressBarClass.prototype.getLoadTarget = function()
- {
- return this.loadTarget;
- };
- ProgressBarClass.prototype.setValue = function(v)
- {
- this.value = v;
- this.invalidate("renderBar");
- };
- ProgressBarClass.prototype.getValue = function()
- {
- return this.value;
- };
- ProgressBarClass.prototype.setMinimum = function(m)
- {
- this.minV = m;
- };
- ProgressBarClass.prototype.getMinimum = function()
- {
- return this.minV;
- };
- ProgressBarClass.prototype.setMaximum = function(m)
- {
- this.maxV = m;
- this.invalidate("renderBar");
- };
- ProgressBarClass.prototype.getMaximum = function()
- {
- return this.maxV;
- };
- ProgressBarClass.prototype.setDisplayText = function(tOrF)
- {
- if(tOrF)
- {
- this.KBText = this.attachMovie("FLabelSymbol","KBT",4,{hostComponent:this});
- this.setStyleProperty("textAlign","center");
- }
- else
- {
- this.KBText.removeMovieClip();
- this.KBText = undefined;
- }
- };
- ProgressBarClass.prototype.setDisplayGraphics = function(tOrF)
- {
- this.displayBar = tOrF;
- if(!tOrF)
- {
- this.growBar.removeMovieClip();
- this.growBar = undefined;
- this.track.removeMovieClip();
- }
- else
- {
- this.attachMovie("Track","track",0);
- this.setSize(this.width);
- }
- };
- ProgressBarClass.prototype.getPercentComplete = function()
- {
- return Math.round((this.value - this.minV) / this.maxV * 100);
- };
- ProgressBarClass.prototype.setPercentComplete = function(p)
- {
- this.value = this.maxV * p / 100 + this.minV;
- this.invalidate("renderBar");
- };
- ProgressBarClass.prototype.setProgress = function(v, t)
- {
- this.value = v;
- this.maxV = t;
- this.invalidate("renderBar");
- };
- ProgressBarClass.prototype.stretchToSize = function(w, leftCap, mid, rightCap)
- {
- var stretchWidth = Math.max(0,w - leftCap._width - rightCap._width);
- mid._width = stretchWidth;
- mid._x = leftCap._x + leftCap._width;
- rightCap._x = mid._x + mid._width;
- };
- ProgressBarClass.prototype.renderBar = function()
- {
- if(this.maxV == 0 || this.value == 0)
- {
- this.growBar.removeMovieClip();
- return undefined;
- }
- this.value = Math.min(this.maxV,this.value);
- if(this.value != this.oldValue)
- {
- this.executeCallBack();
- }
- if(this.growBar == undefined && this.displayBar)
- {
- this.growBar = this.attachMovie("GrowBar","gBar",2);
- }
- var barSize = this.getPercentComplete() * (this.width - 2) / 100;
- this.stretchToSize(barSize,this.growBar.leftBar,this.growBar.midBar,this.growBar.rightBar);
- this.oldValue = this.value;
- this.KBText.setLabel(Math.round(this.getValue() / 1024) + " / " + Math.round(this.maxV / 1024) + " KB");
- };
-