home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 192 / dpcs0204.iso / Internet / AOL / comp01.000 / %COMPANION_DIR% / UI / Default / client.swf / scripts / %3Cdefault package%3E / FProgressBarSymbol.as < prev    next >
Encoding:
Text File  |  2003-10-24  |  4.1 KB  |  151 lines

  1. function ProgressBarClass()
  2. {
  3.    this.init();
  4.    if(this.displayBar == undefined)
  5.    {
  6.       this.displayBar = true;
  7.       this.kBTally = true;
  8.    }
  9.    this.maxV = 100;
  10.    this.minV = 0;
  11.    this.value = 0;
  12.    this.oldValue = 0;
  13.    this.width = this._xscale;
  14.    this._xscale = this._yscale = 100;
  15.    this.boundingBox_mc._visible = false;
  16.    this.setChangeHandler(this.changeHandler);
  17.    if(this.displayBar)
  18.    {
  19.       this.attachMovie("Track","track",0);
  20.    }
  21.    this.setDisplayText(this.kBTally);
  22.    this.setSize(this.width);
  23. }
  24. Object.registerClass("FProgressBarSymbol",ProgressBarClass);
  25. ProgressBarClass.prototype = new FUIComponentClass();
  26. ProgressBarClass.prototype.setSize = function(w, h)
  27. {
  28.    this.width = w;
  29.    this.height = h;
  30.    this.stretchToSize(w,this.track.leftTrack,this.track.midTrack,this.track.rightTrack);
  31.    this.KBText._x = this.track._x;
  32.    this.KBText._y = this.track._y + this.track._height + 0;
  33.    this.KBText.setSize(w);
  34.    this.renderBar();
  35. };
  36. ProgressBarClass.prototype.setLoadTarget = function(mcRef)
  37. {
  38.    this.loadTarget = mcRef;
  39.    this.createEmptyMovieClip("loadPoller",10);
  40.    this.loadPoller.onEnterFrame = function()
  41.    {
  42.       var comp = this._parent.loadTarget;
  43.       this._parent.setProgress(comp.getBytesLoaded(),comp.getBytesTotal());
  44.       if(this._parent.getPercentComplete() >= 100 && this._parent.getValue() > 4)
  45.       {
  46.          delete this.onEnterFrame;
  47.       }
  48.    };
  49. };
  50. ProgressBarClass.prototype.getLoadTarget = function()
  51. {
  52.    return this.loadTarget;
  53. };
  54. ProgressBarClass.prototype.setValue = function(v)
  55. {
  56.    this.value = v;
  57.    this.invalidate("renderBar");
  58. };
  59. ProgressBarClass.prototype.getValue = function()
  60. {
  61.    return this.value;
  62. };
  63. ProgressBarClass.prototype.setMinimum = function(m)
  64. {
  65.    this.minV = m;
  66. };
  67. ProgressBarClass.prototype.getMinimum = function()
  68. {
  69.    return this.minV;
  70. };
  71. ProgressBarClass.prototype.setMaximum = function(m)
  72. {
  73.    this.maxV = m;
  74.    this.invalidate("renderBar");
  75. };
  76. ProgressBarClass.prototype.getMaximum = function()
  77. {
  78.    return this.maxV;
  79. };
  80. ProgressBarClass.prototype.setDisplayText = function(tOrF)
  81. {
  82.    if(tOrF)
  83.    {
  84.       this.KBText = this.attachMovie("FLabelSymbol","KBT",4,{hostComponent:this});
  85.       this.setStyleProperty("textAlign","center");
  86.    }
  87.    else
  88.    {
  89.       this.KBText.removeMovieClip();
  90.       this.KBText = undefined;
  91.    }
  92. };
  93. ProgressBarClass.prototype.setDisplayGraphics = function(tOrF)
  94. {
  95.    this.displayBar = tOrF;
  96.    if(!tOrF)
  97.    {
  98.       this.growBar.removeMovieClip();
  99.       this.growBar = undefined;
  100.       this.track.removeMovieClip();
  101.    }
  102.    else
  103.    {
  104.       this.attachMovie("Track","track",0);
  105.       this.setSize(this.width);
  106.    }
  107. };
  108. ProgressBarClass.prototype.getPercentComplete = function()
  109. {
  110.    return Math.round((this.value - this.minV) / this.maxV * 100);
  111. };
  112. ProgressBarClass.prototype.setPercentComplete = function(p)
  113. {
  114.    this.value = this.maxV * p / 100 + this.minV;
  115.    this.invalidate("renderBar");
  116. };
  117. ProgressBarClass.prototype.setProgress = function(v, t)
  118. {
  119.    this.value = v;
  120.    this.maxV = t;
  121.    this.invalidate("renderBar");
  122. };
  123. ProgressBarClass.prototype.stretchToSize = function(w, leftCap, mid, rightCap)
  124. {
  125.    var stretchWidth = Math.max(0,w - leftCap._width - rightCap._width);
  126.    mid._width = stretchWidth;
  127.    mid._x = leftCap._x + leftCap._width;
  128.    rightCap._x = mid._x + mid._width;
  129. };
  130. ProgressBarClass.prototype.renderBar = function()
  131. {
  132.    if(this.maxV == 0 || this.value == 0)
  133.    {
  134.       this.growBar.removeMovieClip();
  135.       return undefined;
  136.    }
  137.    this.value = Math.min(this.maxV,this.value);
  138.    if(this.value != this.oldValue)
  139.    {
  140.       this.executeCallBack();
  141.    }
  142.    if(this.growBar == undefined && this.displayBar)
  143.    {
  144.       this.growBar = this.attachMovie("GrowBar","gBar",2);
  145.    }
  146.    var barSize = this.getPercentComplete() * (this.width - 2) / 100;
  147.    this.stretchToSize(barSize,this.growBar.leftBar,this.growBar.midBar,this.growBar.rightBar);
  148.    this.oldValue = this.value;
  149.    this.KBText.setLabel(Math.round(this.getValue() / 1024) + " / " + Math.round(this.maxV / 1024) + " KB");
  150. };
  151.