home *** CD-ROM | disk | FTP | other *** search
/ i·claim - visualizing argument / ICLAIM.ISO / pc / glossary.swf / scripts / __Packages / mx / controls / streamingmedia / LoadBar.as < prev    next >
Encoding:
Text File  |  2005-02-24  |  3.2 KB  |  150 lines

  1. class mx.controls.streamingmedia.LoadBar extends MovieClip
  2. {
  3.    var _controller;
  4.    var _fill;
  5.    var _border;
  6.    var _background;
  7.    function LoadBar()
  8.    {
  9.       super();
  10.       this.init();
  11.    }
  12.    function init()
  13.    {
  14.       this._controller = this._parent;
  15.       this.draw();
  16.    }
  17.    function isVertical()
  18.    {
  19.       return !this._controller.horizontal;
  20.    }
  21.    function getCompletionPercentage()
  22.    {
  23.       var _loc2_ = undefined;
  24.       if(this.isVertical())
  25.       {
  26.          _loc2_ = this.yToPercent(this._fill._height);
  27.       }
  28.       else
  29.       {
  30.          _loc2_ = this.xToPercent(this._fill._width);
  31.       }
  32.       return _loc2_;
  33.    }
  34.    function setCompletionPercentage(aPercentage)
  35.    {
  36.       aPercentage = Math.floor(aPercentage);
  37.       if(aPercentage < 0)
  38.       {
  39.          aPercentage = 0;
  40.       }
  41.       else if(aPercentage > 100)
  42.       {
  43.          aPercentage = 100;
  44.       }
  45.       if(this.isVertical())
  46.       {
  47.          this._fill._height = this.percentToY(aPercentage);
  48.          this._fill._y = this.getActualHeight() - this._fill._height - 1;
  49.       }
  50.       else
  51.       {
  52.          this._fill._width = this.percentToX(aPercentage);
  53.       }
  54.    }
  55.    function draw(size)
  56.    {
  57.       var _loc3_ = this.getCompletionPercentage();
  58.       if(this.isVertical())
  59.       {
  60.          if(size == null)
  61.          {
  62.             size = this.getHeight();
  63.          }
  64.          this._y = 8;
  65.          this._border._height = size;
  66.          this._background._height = size - 2;
  67.       }
  68.       else
  69.       {
  70.          if(size == null)
  71.          {
  72.             size = this.getWidth();
  73.          }
  74.          this._x = 8;
  75.          this._border._width = size;
  76.          this._background._width = size - 2;
  77.       }
  78.       this.setCompletionPercentage(_loc3_);
  79.    }
  80.    function getWidth()
  81.    {
  82.       var _loc2_ = undefined;
  83.       if(this.isVertical())
  84.       {
  85.          _loc2_ = 3;
  86.       }
  87.       else
  88.       {
  89.          _loc2_ = this._controller.width - 16;
  90.       }
  91.       return _loc2_;
  92.    }
  93.    function getHeight()
  94.    {
  95.       var _loc2_ = undefined;
  96.       if(this.isVertical())
  97.       {
  98.          if(this._controller.expanded)
  99.          {
  100.             _loc2_ = this.getOpenHeight();
  101.          }
  102.          else
  103.          {
  104.             _loc2_ = this.getClosedHeight();
  105.          }
  106.       }
  107.       else
  108.       {
  109.          _loc2_ = 3;
  110.       }
  111.       return _loc2_;
  112.    }
  113.    function getActualHeight()
  114.    {
  115.       return this._border._height;
  116.    }
  117.    function getActualWidth()
  118.    {
  119.       return this._border._width;
  120.    }
  121.    function getOpenHeight()
  122.    {
  123.       return this._controller.height - 90;
  124.    }
  125.    function getClosedHeight()
  126.    {
  127.       return this._controller.height - 16;
  128.    }
  129.    function xToPercent(x)
  130.    {
  131.       var _loc2_ = 100 * x / (this.getActualWidth() - 2);
  132.       return _loc2_;
  133.    }
  134.    function percentToX(percent)
  135.    {
  136.       var _loc2_ = (this.getWidth() - 2) * (percent / 100);
  137.       return _loc2_;
  138.    }
  139.    function yToPercent(y)
  140.    {
  141.       var _loc2_ = 100 * (y - 0) / (this.getActualHeight() - 2);
  142.       return _loc2_;
  143.    }
  144.    function percentToY(percent)
  145.    {
  146.       var _loc2_ = (this.getActualHeight() - 2) * (percent / 100);
  147.       return _loc2_;
  148.    }
  149. }
  150.