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

  1. class mx.controls.streamingmedia.PlayBarThumb extends MovieClip
  2. {
  3.    var _playBar;
  4.    var _dragging;
  5.    var _wasPlaying;
  6.    var onMouseMove;
  7.    var _enabled;
  8.    var onPress;
  9.    var onRelease;
  10.    var onReleaseOutside;
  11.    function PlayBarThumb()
  12.    {
  13.       super();
  14.       this.init();
  15.    }
  16.    function init()
  17.    {
  18.       this._playBar = this._parent;
  19.       this.enabled = this._playBar.getController().enabled;
  20.    }
  21.    function isVertical()
  22.    {
  23.       return this._playBar.isVertical();
  24.    }
  25.    function handlePress()
  26.    {
  27.       this.startThumbDrag();
  28.    }
  29.    function startThumbDrag()
  30.    {
  31.       this._dragging = true;
  32.       var _loc2_ = this._playBar.getController();
  33.       _loc2_.broadcastEvent("scrubbing",true);
  34.       this._wasPlaying = _loc2_.isPlaying();
  35.       if(this._wasPlaying)
  36.       {
  37.          _loc2_.broadcastEvent("click","pause");
  38.       }
  39.       this.onMouseMove = this.handleMouseMove;
  40.    }
  41.    function onUnload()
  42.    {
  43.       if(this._dragging)
  44.       {
  45.          this.stopThumbDrag();
  46.       }
  47.    }
  48.    function handleRelease()
  49.    {
  50.       if(this._dragging)
  51.       {
  52.          this.stopThumbDrag();
  53.       }
  54.    }
  55.    function handleReleaseOutside()
  56.    {
  57.       if(this._dragging)
  58.       {
  59.          this.stopThumbDrag();
  60.       }
  61.    }
  62.    function stopThumbDrag()
  63.    {
  64.       this._dragging = false;
  65.       var _loc2_ = this._playBar.getController();
  66.       if(this._wasPlaying)
  67.       {
  68.          _loc2_.broadcastEvent("click","play");
  69.       }
  70.       _loc2_.broadcastEvent("scrubbing",false);
  71.       delete this.onMouseMove;
  72.    }
  73.    function handleMouseMove()
  74.    {
  75.       var _loc2_ = this._playBar.getController();
  76.       var _loc8_ = _loc2_.getLoadBar().getCompletionPercentage() / 100;
  77.       if(this.isVertical())
  78.       {
  79.          var _loc6_ = this._playBar.getHeight() - 8;
  80.          var _loc9_ = _loc6_ * (1 - _loc8_) - 2;
  81.          var _loc3_ = this._playBar._ymouse;
  82.          if(_loc3_ < _loc9_)
  83.          {
  84.             _loc3_ = _loc9_;
  85.          }
  86.          else if(_loc3_ > _loc6_)
  87.          {
  88.             _loc3_ = _loc6_;
  89.          }
  90.          this._y = _loc3_;
  91.       }
  92.       else
  93.       {
  94.          var _loc10_ = (this._playBar.getWidth() - 6) * _loc8_;
  95.          var _loc4_ = this._playBar._xmouse;
  96.          if(_loc4_ < 0)
  97.          {
  98.             _loc4_ = 0;
  99.          }
  100.          else if(_loc4_ > _loc10_)
  101.          {
  102.             _loc4_ = _loc10_;
  103.          }
  104.          this._x = _loc4_;
  105.       }
  106.       this._playBar.updateHiliteToMatchThumb();
  107.       var _loc5_ = !this.isVertical() ? this._playBar.xToPercent(this._x) : this._playBar.yToPercent(this._y);
  108.       if(mx.controls.streamingmedia.StreamingMediaConstants.SCRUBBING)
  109.       {
  110.          _loc2_.broadcastEvent("playheadChange",_loc5_);
  111.       }
  112.       var _loc11_ = _loc2_.playTime * 100 / _loc2_.playPercent;
  113.       var _loc7_ = _loc11_ * _loc5_ / 100;
  114.       this._playBar.setTime(_loc7_);
  115.       _loc2_.playPercent = _loc5_;
  116.       _loc2_.playTime = _loc7_;
  117.    }
  118.    function get enabled()
  119.    {
  120.       return this._enabled;
  121.    }
  122.    function set enabled(is)
  123.    {
  124.       this._enabled = is;
  125.       if(is)
  126.       {
  127.          this.onPress = this.handlePress;
  128.          this.onRelease = this.handleRelease;
  129.          this.onReleaseOutside = this.handleReleaseOutside;
  130.       }
  131.       else
  132.       {
  133.          if(this._dragging)
  134.          {
  135.             this.stopThumbDrag();
  136.          }
  137.          delete this.onPress;
  138.          delete this.onRelease;
  139.          delete this.onReleaseOutside;
  140.       }
  141.    }
  142.    function isScrubbing()
  143.    {
  144.       return this._dragging;
  145.    }
  146. }
  147.