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

  1. class mx.controls.streamingmedia.FullScreenToggle extends MovieClip
  2. {
  3.    var _player;
  4.    var _isFull;
  5.    var _originalPlayerX;
  6.    var _originalPlayerY;
  7.    var _originalPlayerWidth;
  8.    var _originalPlayerHeight;
  9.    var _originalAutosize;
  10.    var _waited;
  11.    var onEnterFrame;
  12.    var _maximize;
  13.    var _minimize;
  14.    function FullScreenToggle()
  15.    {
  16.       super();
  17.       this.init();
  18.    }
  19.    function init()
  20.    {
  21.       this._player = this._parent._parent;
  22.       this._isFull = false;
  23.       this.setEnabled(this._player.enabled);
  24.    }
  25.    function isFullScreen()
  26.    {
  27.       return this._isFull;
  28.    }
  29.    function displayFull(noAction)
  30.    {
  31.       this.gotoAndStop("big");
  32.       this._isFull = true;
  33.       if(!noAction)
  34.       {
  35.          this._originalPlayerX = this._player._x;
  36.          this._originalPlayerY = this._player._y;
  37.          this._originalPlayerWidth = this._player.width;
  38.          this._originalPlayerHeight = this._player.height;
  39.          this._originalAutosize = this._player.autoSize;
  40.          var _loc7_ = this._player.getController();
  41.          if(_loc7_.controllerPolicy == "auto" && _loc7_.expanded)
  42.          {
  43.             mx.controls.streamingmedia.Tracer.trace("FullScreenToggle.displayFull: about to call contract");
  44.             _loc7_.contract();
  45.          }
  46.          _loc7_.setNotAnimating(false);
  47.          this._player.autoSize = false;
  48.          var _loc4_ = this.getContainerInfo();
  49.          this._player.setSize(_loc4_.width,_loc4_.height);
  50.          if(_loc4_.origin)
  51.          {
  52.             var _loc5_ = mx.managers.SystemManager.screen;
  53.             mx.controls.streamingmedia.Tracer.trace("FullScreenToggle.displayFull: scr=(" + _loc5_.x + "," + _loc5_.y + ")");
  54.             this._player._x = _loc5_.x;
  55.             this._player._y = _loc5_.y;
  56.          }
  57.          var _loc6_ = this._player.getBounds(_loc4_.container);
  58.          mx.controls.streamingmedia.Tracer.trace("FullScreenToggle.displayFull: bounds=(" + _loc6_.xMin + "," + _loc6_.yMin + ")");
  59.          if(_loc4_.origin)
  60.          {
  61.             this._player._x += _loc5_.x;
  62.             this._player._y += _loc5_.y;
  63.          }
  64.          else
  65.          {
  66.             this._player._x += _loc4_.x;
  67.             this._player._y += _loc4_.y;
  68.          }
  69.          this._player._x -= _loc6_.xMin;
  70.          this._player._y -= _loc6_.yMin;
  71.          this._waited = false;
  72.          this.onEnterFrame = this.delayedBarRefresh;
  73.          var _loc3_ = this.getOtherToggles();
  74.          var _loc2_ = 0;
  75.          while(_loc2_ < _loc3_.length)
  76.          {
  77.             _loc3_[_loc2_].displayFull(true);
  78.             _loc2_ = _loc2_ + 1;
  79.          }
  80.       }
  81.    }
  82.    function getContainerInfo()
  83.    {
  84.       var _loc4_ = undefined;
  85.       var _loc6_ = this.getScrollViewAncestor(this._player);
  86.       if(_loc6_ == null)
  87.       {
  88.          var _loc5_ = mx.managers.SystemManager.screen;
  89.          _loc4_ = {container:_root,width:_loc5_.width,height:_loc5_.height,x:0,y:0,origin:true};
  90.       }
  91.       else
  92.       {
  93.          var _loc3_ = _loc6_.getViewMetrics();
  94.          _loc4_ = {container:_loc6_,width:_loc6_.width - _loc3_.left - _loc3_.right,height:_loc6_.height - _loc3_.top - _loc3_.bottom,x:_loc3_.left,y:_loc3_.top,origin:false};
  95.       }
  96.       return _loc4_;
  97.    }
  98.    function getScrollViewAncestor(anMC)
  99.    {
  100.       var _loc3_ = undefined;
  101.       if(anMC == _root)
  102.       {
  103.          _loc3_ = null;
  104.       }
  105.       else if(anMC instanceof mx.core.ScrollView)
  106.       {
  107.          _loc3_ = anMC;
  108.       }
  109.       else
  110.       {
  111.          _loc3_ = this.getScrollViewAncestor(anMC._parent);
  112.       }
  113.       return _loc3_;
  114.    }
  115.    function delayedBarRefresh()
  116.    {
  117.       if(!this._waited)
  118.       {
  119.          this._waited = true;
  120.       }
  121.       else
  122.       {
  123.          delete this.onEnterFrame;
  124.          this._player.getController().refreshBars();
  125.       }
  126.    }
  127.    function displayNormal(noAction)
  128.    {
  129.       this.gotoAndStop("small");
  130.       this._isFull = false;
  131.       if(!noAction)
  132.       {
  133.          var _loc4_ = this._player.getController();
  134.          if(_loc4_.controllerPolicy == "auto" && _loc4_.expanded)
  135.          {
  136.             mx.controls.streamingmedia.Tracer.trace("FullScreenToggle.displayNormal: about to call contract");
  137.             _loc4_.contract();
  138.          }
  139.          _loc4_.setNotAnimating(false);
  140.          this._player.autoSize = this._originalAutosize;
  141.          this._player.setSize(this._originalPlayerWidth,this._originalPlayerHeight);
  142.          this._player._x = this._originalPlayerX;
  143.          this._player._y = this._originalPlayerY;
  144.          this._waited = false;
  145.          this.onEnterFrame = this.delayedBarRefresh;
  146.          var _loc3_ = this.getOtherToggles();
  147.          var _loc2_ = 0;
  148.          while(_loc2_ < _loc3_.length)
  149.          {
  150.             _loc3_[_loc2_].displayNormal(true);
  151.             _loc2_ = _loc2_ + 1;
  152.          }
  153.       }
  154.    }
  155.    function toggleDisplay()
  156.    {
  157.       if(this._isFull)
  158.       {
  159.          this.displayNormal();
  160.       }
  161.       else
  162.       {
  163.          this.displayFull();
  164.       }
  165.    }
  166.    function getAllToggles()
  167.    {
  168.       return this._parent.getAllToggles();
  169.    }
  170.    function getOtherToggles()
  171.    {
  172.       var _loc3_ = this.getAllToggles();
  173.       var _loc2_ = 0;
  174.       while(_loc2_ < _loc3_.length)
  175.       {
  176.          if(_loc3_[_loc2_] == this)
  177.          {
  178.             _loc3_.splice(_loc2_,1);
  179.             break;
  180.          }
  181.          _loc2_ = _loc2_ + 1;
  182.       }
  183.       return _loc3_;
  184.    }
  185.    function getPlayer()
  186.    {
  187.       return this._player;
  188.    }
  189.    function getEnabled()
  190.    {
  191.       return this._player.enabled;
  192.    }
  193.    function setEnabled(is)
  194.    {
  195.       mx.controls.streamingmedia.Tracer.trace("FullScreenToggle.setEnabled: " + is);
  196.       this._maximize.setEnabled(is);
  197.       this._minimize.setEnabled(is);
  198.    }
  199. }
  200.