home *** CD-ROM | disk | FTP | other *** search
/ i·claim - visualizing argument / ICLAIM.ISO / mac / t_02.swf / scripts / __Packages / mx / controls / streamingmedia / PlayPauseButton.as < prev    next >
Text File  |  2005-02-25  |  3KB  |  100 lines

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