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

  1. class mx.controls.streamingmedia.PlayPauseButton extends MovieClip
  2. {
  3.    var _controller;
  4.    var _playPauseButton;
  5.    var _isPlaying;
  6.    function PlayPauseButton()
  7.    {
  8.       super();
  9.       this.init();
  10.    }
  11.    function init()
  12.    {
  13.       this._controller = this._parent._parent;
  14.       this.attachMovie("Button","_playPauseButton",1);
  15.       this._playPauseButton.setSize(50,22);
  16.       this._playPauseButton._x = 0;
  17.       this._playPauseButton._y = 0;
  18.       this._playPauseButton.addEventListener("click",this);
  19.       this._isPlaying = !this._controller.isPlaying();
  20.       this.enabled = this._controller.enabled;
  21.       this.tabEnabled = false;
  22.       this.tabChildren = true;
  23.    }
  24.    function showPlayButton()
  25.    {
  26.       mx.controls.streamingmedia.Tracer.trace("PlayPauseButton.showPlayButton");
  27.       this._isPlaying = true;
  28.       this.assignIcon();
  29.    }
  30.    function showPauseButton()
  31.    {
  32.       mx.controls.streamingmedia.Tracer.trace("PlayPauseButton.showPauseButton");
  33.       this._isPlaying = false;
  34.       this.assignIcon();
  35.    }
  36.    function get enabled()
  37.    {
  38.       return this._playPauseButton.enabled;
  39.    }
  40.    function set enabled(is)
  41.    {
  42.       this._playPauseButton.enabled = is;
  43.       this.assignIcon();
  44.    }
  45.    function assignIcon()
  46.    {
  47.       var _loc3_ = this.enabled;
  48.       var _loc5_ = this._isPlaying;
  49.       mx.controls.streamingmedia.Tracer.trace("PlayPauseButton.assignIcon: start: enabled=" + _loc3_ + ", play=" + _loc5_);
  50.       var _loc2_ = "";
  51.       if(_loc5_)
  52.       {
  53.          _loc2_ = !_loc3_ ? "icon.play-disabled" : "icon.play";
  54.       }
  55.       else
  56.       {
  57.          _loc2_ = !_loc3_ ? "icon.pause-disabled" : "icon.pause";
  58.       }
  59.       mx.controls.streamingmedia.Tracer.trace("PlayPauseButton.assignIcon: icon=" + _loc2_);
  60.       var _loc4_ = this._playPauseButton.enabled;
  61.       if(!_loc4_)
  62.       {
  63.          this._playPauseButton.enabled = true;
  64.       }
  65.       this._playPauseButton.icon = _loc2_;
  66.       if(!_loc4_)
  67.       {
  68.          this._playPauseButton.enabled = false;
  69.       }
  70.       mx.controls.streamingmedia.Tracer.trace("PlayPauseButton.assignIcon: done");
  71.    }
  72.    function click(ev)
  73.    {
  74.       if(this._isPlaying)
  75.       {
  76.          this.playClick();
  77.       }
  78.       else
  79.       {
  80.          this.pauseClick();
  81.       }
  82.    }
  83.    function playClick()
  84.    {
  85.       var _loc2_ = this._controller;
  86.       mx.controls.streamingmedia.Tracer.trace("PlayButton.click: playAtBeginning=" + _loc2_.playAtBeginning);
  87.       if(_loc2_.playAtBeginning)
  88.       {
  89.          _loc2_.broadcastEvent("playheadChange",0);
  90.          mx.controls.streamingmedia.Tracer.trace("PlayButton.click: playAtBeginning=false");
  91.          _loc2_.playAtBeginning = false;
  92.       }
  93.       _loc2_.broadcastEvent("click","play");
  94.       _loc2_.setPlaying(true);
  95.    }
  96.    function pauseClick()
  97.    {
  98.       var _loc2_ = this._controller;
  99.       _loc2_.broadcastEvent("click","pause");
  100.       _loc2_.setPlaying(false);
  101.    }
  102. }
  103.