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

  1. class mx.controls.streamingmedia.MiniPlayBar extends MovieClip
  2. {
  3.    var _controller;
  4.    var _thumb;
  5.    var _hilite;
  6.    var _tray;
  7.    function MiniPlayBar()
  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._thumb._y);
  27.       }
  28.       else
  29.       {
  30.          _loc2_ = this.xToPercent(this._thumb._x);
  31.       }
  32.       return _loc2_;
  33.    }
  34.    function setCompletionPercentage(aPercentage)
  35.    {
  36.       aPercentage = Math.floor(aPercentage);
  37.       if(aPercentage < 1)
  38.       {
  39.          aPercentage = 1;
  40.       }
  41.       else if(aPercentage > 100)
  42.       {
  43.          aPercentage = 100;
  44.       }
  45.       if(this.isVertical())
  46.       {
  47.          var _loc3_ = this.percentToY(aPercentage);
  48.          this._thumb._y = this.getActualHeight() - _loc3_ - 1;
  49.          this._hilite._height = _loc3_ - 1;
  50.          this._hilite._y = this.getActualHeight() - _loc3_ - 2;
  51.       }
  52.       else
  53.       {
  54.          var _loc4_ = this.percentToX(aPercentage);
  55.          this._thumb._x = _loc4_;
  56.          this._hilite._width = _loc4_ - 1;
  57.       }
  58.    }
  59.    function getController()
  60.    {
  61.       return this._controller;
  62.    }
  63.    function draw(h)
  64.    {
  65.       if(this.isVertical())
  66.       {
  67.          this._y = 8;
  68.          if(h == null)
  69.          {
  70.             h = this.getHeight();
  71.          }
  72.          this._tray.setHeight(h);
  73.       }
  74.       else
  75.       {
  76.          var _loc3_ = this.getWidth();
  77.          this._x = 8;
  78.          this._tray.setWidth(this.getWidth());
  79.       }
  80.       this.setCompletionPercentage(this._controller.playPercent);
  81.    }
  82.    function getWidth()
  83.    {
  84.       var _loc2_ = !this.isVertical() ? this._controller.width - 16 : 6;
  85.       return _loc2_;
  86.    }
  87.    function getHeight()
  88.    {
  89.       var _loc2_ = !this.isVertical() ? 6 : this._controller.height - 16;
  90.       return _loc2_;
  91.    }
  92.    function getActualHeight()
  93.    {
  94.       var _loc2_ = this._tray.getHeight();
  95.       return _loc2_;
  96.    }
  97.    function xToPercent(x)
  98.    {
  99.       var _loc2_ = 100 * x / (this.getWidth() - 2);
  100.       return _loc2_;
  101.    }
  102.    function percentToX(percent)
  103.    {
  104.       var _loc2_ = (this.getWidth() - 2) * (percent / 100);
  105.       return _loc2_;
  106.    }
  107.    function yToPercent(y)
  108.    {
  109.       var _loc2_ = 100 * (y - 1) / (this.getActualHeight() - 3);
  110.       return _loc2_;
  111.    }
  112.    function percentToY(percent)
  113.    {
  114.       var _loc2_ = (this.getActualHeight() - 3) * (percent / 100) + 1;
  115.       return _loc2_;
  116.    }
  117. }
  118.