home *** CD-ROM | disk | FTP | other *** search
/ i·claim - visualizing argument / ICLAIM.ISO / pc / gloss.swf / scripts / __Packages / mx / controls / streamingmedia / ScreenAccommodator.as < prev    next >
Encoding:
Text File  |  2005-02-26  |  2.3 KB  |  85 lines

  1. class mx.controls.streamingmedia.ScreenAccommodator
  2. {
  3.    var containee;
  4.    var container;
  5.    var beforeInit;
  6.    var initId;
  7.    var wasAlreadyDisabled;
  8.    var initAction = "nothing";
  9.    function ScreenAccommodator(aContainee)
  10.    {
  11.       this.containee = aContainee;
  12.       this.container = this.getContainingScreen();
  13.       if(this.container != null)
  14.       {
  15.          var _loc2_ = this.container.visible;
  16.          this.beforeInit = false;
  17.          this.container.addEventListener("hide",this);
  18.          this.container.addEventListener("reveal",this);
  19.          if(!_loc2_)
  20.          {
  21.             this.beforeInit = true;
  22.             this.initId = setInterval(this,"disableContainee",50);
  23.          }
  24.       }
  25.    }
  26.    function disableContainee()
  27.    {
  28.       if(this.initAction == "nothing" || this.initAction == "hide")
  29.       {
  30.          mx.controls.streamingmedia.Tracer.trace("ScreenAccommodator.disableContainee: disabling " + this.containee);
  31.          this.containee.enabled = false;
  32.       }
  33.       clearInterval(this.initId);
  34.       this.beforeInit = false;
  35.    }
  36.    function getContainingScreen()
  37.    {
  38.       var _loc4_ = null;
  39.       var _loc3_ = this.containee._parent;
  40.       while(_loc4_ == null && _loc3_ != _root)
  41.       {
  42.          if(_loc3_ instanceof mx.screens.Screen)
  43.          {
  44.             _loc4_ = _loc3_;
  45.          }
  46.          else
  47.          {
  48.             _loc3_ = _loc3_._parent;
  49.          }
  50.       }
  51.       return _loc4_;
  52.    }
  53.    function handleEvent(ev)
  54.    {
  55.       mx.controls.streamingmedia.Tracer.trace("ScreenAccommodator.handleEvent: " + ev.type + " for " + this.containee);
  56.       if(ev.type == "hide")
  57.       {
  58.          if(this.beforeInit)
  59.          {
  60.             this.initAction = "hide";
  61.          }
  62.          else if(this.containee.enabled)
  63.          {
  64.             this.wasAlreadyDisabled = false;
  65.             this.containee.enabled = false;
  66.          }
  67.          else
  68.          {
  69.             this.wasAlreadyDisabled = true;
  70.          }
  71.       }
  72.       else if(ev.type == "reveal")
  73.       {
  74.          if(this.beforeInit)
  75.          {
  76.             this.initAction = "reveal";
  77.          }
  78.          else if(!this.wasAlreadyDisabled && this.containee.visible)
  79.          {
  80.             this.containee.enabled = true;
  81.          }
  82.       }
  83.    }
  84. }
  85.