home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Nave / sky-chopper.swf / scripts / __Packages / mx / controls / MediaController.as < prev    next >
Encoding:
Text File  |  2005-09-29  |  25.1 KB  |  796 lines

  1. class mx.controls.MediaController extends mx.core.UIComponent
  2. {
  3.    var _lastProgressMediaType;
  4.    var _controllerPolicy;
  5.    var _horizontal;
  6.    var _enabled;
  7.    var _priorPolicy;
  8.    var _activePlayControl;
  9.    var _backgroundStyle;
  10.    var _isOpen;
  11.    var _priorMouseOver;
  12.    var _closeId;
  13.    var _openId;
  14.    var _isPlaying;
  15.    var _playPercent;
  16.    var _playTime;
  17.    var _volume;
  18.    var playAtBeginning;
  19.    var _screenAccommodator;
  20.    var _playBar;
  21.    var _miniPlayBar;
  22.    var _loadBar;
  23.    var _volumeControl;
  24.    var _buttons;
  25.    var _chrome;
  26.    var _secondChrome;
  27.    var _secondChromeClosedHeight;
  28.    var _secondChromeOpenHeight;
  29.    var _secondChromeClosedWidth;
  30.    var _secondChromeOpenWidth;
  31.    var _secondChromeFixedEnd;
  32.    var _animationStart;
  33.    var _animationOpen;
  34.    var onEnterFrame;
  35.    var _loadPercent;
  36.    var dispatchEvent;
  37.    var _listenForPlayheadMoveEvent;
  38.    var _notAnimating;
  39.    var _strings;
  40.    var _openUpOrLeft;
  41.    static var symbolName = "MediaController";
  42.    static var symbolOwner = mx.controls.MediaController;
  43.    var className = "MediaController";
  44.    static var version = "2.0.0.360";
  45.    var clipParameters = {controllerPolicy:"auto",horizontal:true,activePlayControl:"pause",backgroundStyle:"default"};
  46.    static var MINIMUM_HORIZONTAL_WIDTH = 202;
  47.    static var CLOSED_HORIZONTAL_HEIGHT = 25;
  48.    static var MINIMUM_HORIZONTAL_OPEN_HEIGHT = 63;
  49.    static var LOADBAR_HORIZONTAL_CLOSED_Y = 14;
  50.    static var LOADBAR_HORIZONTAL_OPEN_Y = 24;
  51.    static var MINIMUM_VERTICAL_HEIGHT = 202;
  52.    static var CLOSED_VERTICAL_WIDTH = 25;
  53.    static var MINIMUM_VERTICAL_OPEN_WIDTH = 80;
  54.    static var LOADBAR_VERTICAL_CLOSED_X = 14;
  55.    static var MINIPLAYBAR_VERTICAL_CLOSED_X = 8;
  56.    static var ANIMATION_TIME = 250;
  57.    static var CLOSE_DELAY = 1000;
  58.    static var OPEN_DELAY = 100;
  59.    static var LOCALIZED_FILE = "streamingmediacontroller.xml";
  60.    static var H_BORDER = 8;
  61.    static var V_BORDER = 8;
  62.    var _animating = false;
  63.    function MediaController()
  64.    {
  65.       super();
  66.    }
  67.    function get lastProgressMediaType()
  68.    {
  69.       return this._lastProgressMediaType;
  70.    }
  71.    function init(Void)
  72.    {
  73.       mx.controls.streamingmedia.Tracer.trace("MediaController.init: start: policy=" + this._controllerPolicy);
  74.       this.initializeParameters();
  75.       mx.controls.streamingmedia.Tracer.trace("MediaController.init: after initializeParameters: policy=" + this._controllerPolicy);
  76.       var _loc3_ = this._width;
  77.       var _loc4_ = this._height;
  78.       super.init();
  79.       if(this._horizontal)
  80.       {
  81.          _loc3_ = Math.max(mx.controls.MediaController.MINIMUM_HORIZONTAL_WIDTH,_loc3_);
  82.          _loc4_ = Math.max(mx.controls.MediaController.MINIMUM_HORIZONTAL_OPEN_HEIGHT,_loc4_);
  83.       }
  84.       else
  85.       {
  86.          _loc3_ = Math.max(mx.controls.MediaController.MINIMUM_VERTICAL_OPEN_WIDTH,_loc3_);
  87.          _loc4_ = Math.max(mx.controls.MediaController.MINIMUM_VERTICAL_HEIGHT,_loc4_);
  88.       }
  89.       this.setSize(_loc3_,_loc4_,true);
  90.       mx.controls.streamingmedia.Tracer.trace("MediaController.init: after setSize " + this.width + "x" + this.height + " at (" + this._x + "," + this._y + ")");
  91.       this._enabled = true;
  92.       this._priorPolicy = this._controllerPolicy;
  93.       this.createDefaultStrings();
  94.       mx.controls.streamingmedia.Tracer.trace("MediaController.init: Initialized properties:");
  95.       mx.controls.streamingmedia.Tracer.trace("  controllerPolicy=" + this._controllerPolicy);
  96.       mx.controls.streamingmedia.Tracer.trace("  horizontal=" + this._horizontal);
  97.       mx.controls.streamingmedia.Tracer.trace("  activePlayControl=" + this._activePlayControl);
  98.       mx.controls.streamingmedia.Tracer.trace("  backgroundStyle=" + this._backgroundStyle);
  99.       if(this._controllerPolicy == "auto")
  100.       {
  101.          this._isOpen = false;
  102.          this._priorMouseOver = false;
  103.          this._closeId = null;
  104.          this._openId = null;
  105.          Mouse.addListener(this);
  106.          this.gotoAndStop(this.getClosedFrameName());
  107.       }
  108.       else if(this._controllerPolicy == "on")
  109.       {
  110.          this._isOpen = true;
  111.          this.gotoAndStop(this.getOpenFrameName());
  112.       }
  113.       else if(this._controllerPolicy == "off")
  114.       {
  115.          this._isOpen = false;
  116.          this.gotoAndStop(this.getClosedFrameName());
  117.       }
  118.       this._isPlaying = this._activePlayControl == "pause";
  119.       this._playPercent = 0;
  120.       this._playTime = 0;
  121.       this._volume = mx.controls.streamingmedia.StreamingMediaConstants.DEFAULT_VOLUME;
  122.       this.setOpenUpOrLeft(false);
  123.       this.setListeningForPlayheadMoveEvent(true);
  124.       this.tabEnabled = false;
  125.       this.tabChildren = true;
  126.       this.playAtBeginning = false;
  127.       this._screenAccommodator = new mx.controls.streamingmedia.ScreenAccommodator(this);
  128.       this.redraw(true);
  129.    }
  130.    function initializeParameters()
  131.    {
  132.       if(this.horizontal == null)
  133.       {
  134.          this.horizontal = true;
  135.       }
  136.       if(this.controllerPolicy == null)
  137.       {
  138.          this.controllerPolicy = "auto";
  139.       }
  140.       if(this.backgroundStyle == null)
  141.       {
  142.          this.backgroundStyle = "default";
  143.       }
  144.       if(this.activePlayControl == null)
  145.       {
  146.          this.activePlayControl = "pause";
  147.       }
  148.    }
  149.    function getOpenFrameName()
  150.    {
  151.       return !this._horizontal ? "openVertical" : "openHorizontal";
  152.    }
  153.    function getClosedFrameName()
  154.    {
  155.       return !this._horizontal ? "closedVertical" : "closedHorizontal";
  156.    }
  157.    function draw(Void)
  158.    {
  159.       if(this._isOpen)
  160.       {
  161.          this.gotoAndStop(this.getOpenFrameName());
  162.          this._playBar.draw();
  163.       }
  164.       else
  165.       {
  166.          this.gotoAndStop(this.getClosedFrameName());
  167.          this._miniPlayBar.draw();
  168.       }
  169.       this._loadBar.draw();
  170.       if(this._horizontal)
  171.       {
  172.          this.positionControlsHorizontal();
  173.       }
  174.       else
  175.       {
  176.          this.positionControlsVertical();
  177.       }
  178.       this.drawChrome();
  179.    }
  180.    function positionControlsVertical()
  181.    {
  182.       if(this._isOpen)
  183.       {
  184.          this._volumeControl._x = (this.width - this._volumeControl._width) / 2;
  185.          this._volumeControl._y = this.height - this._volumeControl._height - 8;
  186.          this._buttons._x = (this.width - this._buttons._width) / 2;
  187.          this._buttons._y = this.height - this._buttons._height - this._volumeControl._height - 16;
  188.          this._playBar._x = (this.width - this._playBar._width) / 2;
  189.          this._loadBar._x = this._playBar._x + this._playBar._width - 4;
  190.       }
  191.       else
  192.       {
  193.          this._loadBar._x = mx.controls.MediaController.LOADBAR_VERTICAL_CLOSED_X;
  194.          this._miniPlayBar._x = mx.controls.MediaController.MINIPLAYBAR_VERTICAL_CLOSED_X;
  195.       }
  196.    }
  197.    function positionControlsHorizontal()
  198.    {
  199.       if(this._isOpen)
  200.       {
  201.          this._loadBar._y = mx.controls.MediaController.LOADBAR_HORIZONTAL_OPEN_Y;
  202.          this._buttons._x = 8;
  203.          this._buttons._y = this.height - this._buttons._height - 8;
  204.          this._volumeControl._x = this.width - this._volumeControl._width - 8;
  205.          this._volumeControl._y = this.height - this._volumeControl._height - 8;
  206.       }
  207.       else
  208.       {
  209.          this._loadBar._y = mx.controls.MediaController.LOADBAR_HORIZONTAL_CLOSED_Y;
  210.       }
  211.    }
  212.    function drawChrome(wi, he)
  213.    {
  214.       if(wi == null)
  215.       {
  216.          if(this._horizontal)
  217.          {
  218.             wi = this.width;
  219.          }
  220.          else
  221.          {
  222.             wi = !this._isOpen ? mx.controls.MediaController.CLOSED_VERTICAL_WIDTH : this.width;
  223.          }
  224.       }
  225.       if(he == null)
  226.       {
  227.          if(this._horizontal)
  228.          {
  229.             he = !this._isOpen ? mx.controls.MediaController.CLOSED_HORIZONTAL_HEIGHT : this.height;
  230.          }
  231.          else
  232.          {
  233.             he = this.height;
  234.          }
  235.       }
  236.       this._chrome.visible = this.backgroundStyle == "default";
  237.       this._chrome.showToggles = false;
  238.       this._chrome.setSize(wi,he);
  239.       this._chrome.draw();
  240.    }
  241.    function addSecondChrome(theChrome, closedHeight, openHeight, closedWidth, openWidth, fixedEnd)
  242.    {
  243.       this._secondChrome = theChrome;
  244.       this._secondChromeClosedHeight = closedHeight;
  245.       this._secondChromeOpenHeight = openHeight;
  246.       this._secondChromeClosedWidth = closedWidth;
  247.       this._secondChromeOpenWidth = openWidth;
  248.       this._secondChromeFixedEnd = fixedEnd;
  249.    }
  250.    function removeSecondChrome()
  251.    {
  252.       this._secondChrome = null;
  253.    }
  254.    function get expanded()
  255.    {
  256.       return this._isOpen;
  257.    }
  258.    function onMouseMove()
  259.    {
  260.       var _loc5_ = _root._xmouse;
  261.       var _loc4_ = _root._ymouse;
  262.       var _loc3_ = this.hitTest(_loc5_,_loc4_,true);
  263.       if(_loc3_ && this._closeId != null || this.isNotAnimating())
  264.       {
  265.          clearInterval(this._closeId);
  266.          this._closeId = null;
  267.       }
  268.       if(!_loc3_ && this._openId != null || this.isNotAnimating())
  269.       {
  270.          clearInterval(this._openId);
  271.          this._openId = null;
  272.       }
  273.       if(_loc3_ && !this._isOpen && this._controllerPolicy == "auto" && this._openId == null && !this.isNotAnimating())
  274.       {
  275.          this._openId = setInterval(this,"expand",mx.controls.MediaController.OPEN_DELAY);
  276.       }
  277.       else if(!_loc3_ && this._isOpen && this._controllerPolicy == "auto" && this._closeId == null && !this.isNotAnimating())
  278.       {
  279.          this._closeId = setInterval(this,"contract",mx.controls.MediaController.CLOSE_DELAY);
  280.       }
  281.       this._priorMouseOver = _loc3_;
  282.    }
  283.    function expand(force)
  284.    {
  285.       clearInterval(this._openId);
  286.       this._openId = null;
  287.       if(this._controllerPolicy == "auto" || force)
  288.       {
  289.          this._isOpen = true;
  290.          this._animationStart = getTimer();
  291.          this._animationOpen = true;
  292.          this._priorMouseOver = true;
  293.          this.onEnterFrame = this.animate;
  294.       }
  295.    }
  296.    function contract(force)
  297.    {
  298.       mx.controls.streamingmedia.Tracer.trace("MediaController.contract: force=" + force + ", animating=" + this._animating + ", opening=" + this._animationOpen);
  299.       if(this._animating && !this._animationOpen)
  300.       {
  301.          return undefined;
  302.       }
  303.       clearInterval(this._closeId);
  304.       this._closeId = null;
  305.       if(this._controllerPolicy == "auto" || force)
  306.       {
  307.          this._isOpen = false;
  308.          this._animationStart = getTimer();
  309.          this._animationOpen = false;
  310.          this._priorMouseOver = false;
  311.          this.gotoAndStop(this.getClosedFrameName());
  312.          this.animate();
  313.          this.onEnterFrame = this.animate;
  314.       }
  315.    }
  316.    function animate()
  317.    {
  318.       this._animating = true;
  319.       var _loc4_ = getTimer() - this._animationStart;
  320.       var _loc3_ = Math.min(1,_loc4_ / mx.controls.MediaController.ANIMATION_TIME);
  321.       mx.controls.streamingmedia.Tracer.trace("MediaController.animate: _animationStart=" + this._animationStart + ", elapsed=" + _loc4_ + ", portion=" + _loc3_ + ", ANIMATION_TIME=" + mx.controls.MediaController.ANIMATION_TIME);
  322.       this.sizeMainChrome(_loc3_);
  323.       if(this._secondChrome != null)
  324.       {
  325.          this.sizeSecondChrome(_loc3_);
  326.       }
  327.       this.animateBars(_loc3_);
  328.       if(_loc4_ >= mx.controls.MediaController.ANIMATION_TIME || _global.isLivePreview)
  329.       {
  330.          this.animationDone();
  331.       }
  332.    }
  333.    function animationDone()
  334.    {
  335.       mx.controls.streamingmedia.Tracer.trace("MediaController.animationDone");
  336.       this._animating = false;
  337.       delete this.onEnterFrame;
  338.       this.refreshBars();
  339.       if(this._animationOpen)
  340.       {
  341.          this.gotoAndStop(this.getOpenFrameName());
  342.       }
  343.       this.redraw(true);
  344.    }
  345.    function sizeMainChrome(portion)
  346.    {
  347.       var _loc2_ = this.height;
  348.       var _loc3_ = this.width;
  349.       if(this._horizontal)
  350.       {
  351.          var _loc4_ = (this.height - mx.controls.MediaController.CLOSED_HORIZONTAL_HEIGHT) * portion;
  352.          if(this._animationOpen)
  353.          {
  354.             _loc2_ = mx.controls.MediaController.CLOSED_HORIZONTAL_HEIGHT + _loc4_;
  355.          }
  356.          else
  357.          {
  358.             _loc2_ = this.height - _loc4_;
  359.          }
  360.       }
  361.       else
  362.       {
  363.          _loc4_ = (this.width - mx.controls.MediaController.CLOSED_VERTICAL_WIDTH) * portion;
  364.          if(this._animationOpen)
  365.          {
  366.             _loc3_ = mx.controls.MediaController.CLOSED_VERTICAL_WIDTH + _loc4_;
  367.          }
  368.          else
  369.          {
  370.             _loc3_ = this.width - _loc4_;
  371.          }
  372.       }
  373.       if(this.isOpenUpOrLeft())
  374.       {
  375.          var _loc6_ = this._chrome.width - _loc3_;
  376.          var _loc5_ = this._chrome.height - _loc2_;
  377.          this._x += _loc6_;
  378.          this._y += _loc5_;
  379.       }
  380.       this.drawChrome(_loc3_,_loc2_);
  381.    }
  382.    function sizeSecondChrome(portion)
  383.    {
  384.       var _loc3_ = undefined;
  385.       var _loc4_ = undefined;
  386.       var _loc2_ = undefined;
  387.       if(this._horizontal)
  388.       {
  389.          _loc4_ = this._secondChromeClosedWidth;
  390.          _loc2_ = (this._secondChromeOpenHeight - this._secondChromeClosedHeight) * portion;
  391.          _loc3_ = !this._animationOpen ? this._secondChromeOpenHeight - _loc2_ : this._secondChromeClosedHeight + _loc2_;
  392.          if(this._secondChromeFixedEnd)
  393.          {
  394.             this._secondChrome._y = this._secondChrome._y - _loc3_ + this._secondChrome.height;
  395.          }
  396.       }
  397.       else
  398.       {
  399.          _loc3_ = this._secondChromeClosedHeight;
  400.          _loc2_ = (this._secondChromeOpenWidth - this._secondChromeClosedWidth) * portion;
  401.          _loc4_ = !this._animationOpen ? this._secondChromeOpenWidth - _loc2_ : this._secondChromeClosedWidth + _loc2_;
  402.          if(this._secondChromeFixedEnd)
  403.          {
  404.             this._secondChrome._x = this._secondChrome._x - _loc4_ + this._secondChrome.width;
  405.          }
  406.       }
  407.       this._secondChrome.setSize(_loc4_,_loc3_);
  408.       this._secondChrome.draw();
  409.    }
  410.    function animateBars(portion)
  411.    {
  412.       var _loc2_ = undefined;
  413.       if(this._horizontal)
  414.       {
  415.          _loc2_ = (mx.controls.MediaController.LOADBAR_HORIZONTAL_OPEN_Y - mx.controls.MediaController.LOADBAR_HORIZONTAL_CLOSED_Y) * portion;
  416.          var _loc8_ = !this._animationOpen ? mx.controls.MediaController.LOADBAR_HORIZONTAL_OPEN_Y - _loc2_ : mx.controls.MediaController.LOADBAR_HORIZONTAL_CLOSED_Y + _loc2_;
  417.          this._loadBar._y = _loc8_;
  418.       }
  419.       else
  420.       {
  421.          var _loc5_ = this._chrome.width / 2;
  422.          _loc2_ = (_loc5_ - mx.controls.MediaController.MINIPLAYBAR_VERTICAL_CLOSED_X) * portion;
  423.          _loc2_ = Math.max(0,_loc2_);
  424.          var _loc9_ = !this._animationOpen ? _loc5_ - _loc2_ : mx.controls.MediaController.MINIPLAYBAR_VERTICAL_CLOSED_X + _loc2_;
  425.          this._miniPlayBar._x = _loc9_;
  426.          this._loadBar._x = this._miniPlayBar._x + this._miniPlayBar._width;
  427.          var _loc3_ = this._loadBar.getClosedHeight();
  428.          var _loc4_ = this._loadBar.getOpenHeight();
  429.          _loc2_ = (_loc3_ - _loc4_) * portion;
  430.          var _loc6_ = !this._animationOpen ? _loc4_ + _loc2_ : _loc3_ - _loc2_;
  431.          this._loadBar.draw(_loc6_);
  432.          this._miniPlayBar.draw(_loc6_);
  433.       }
  434.    }
  435.    function getLoadBar()
  436.    {
  437.       return this._loadBar;
  438.    }
  439.    function setLoadBarFull()
  440.    {
  441.       this._loadBar.setCompletionPercentage(100);
  442.       this._loadPercent = 100;
  443.    }
  444.    function refreshBars()
  445.    {
  446.       mx.controls.streamingmedia.Tracer.trace("MediaController.refreshBars: load=" + this._loadPercent + ", play=" + this._playPercent);
  447.       this._loadBar.setCompletionPercentage(this._loadPercent);
  448.       this._playBar.setCompletionPercentage(this._playPercent);
  449.       this._miniPlayBar.setCompletionPercentage(this._playPercent);
  450.    }
  451.    function getLoadPercent()
  452.    {
  453.       return this._loadPercent;
  454.    }
  455.    function getMinimumOpenHeight()
  456.    {
  457.       var _loc2_ = !this._horizontal ? mx.controls.MediaController.MINIMUM_VERTICAL_HEIGHT : mx.controls.MediaController.MINIMUM_HORIZONTAL_OPEN_HEIGHT;
  458.       return _loc2_;
  459.    }
  460.    function getMinimumClosedHeight()
  461.    {
  462.       var _loc2_ = !this._horizontal ? mx.controls.MediaController.MINIMUM_VERTICAL_HEIGHT : mx.controls.MediaController.CLOSED_HORIZONTAL_HEIGHT;
  463.       return _loc2_;
  464.    }
  465.    function getMinimumOpenWidth()
  466.    {
  467.       var _loc2_ = !this._horizontal ? mx.controls.MediaController.MINIMUM_VERTICAL_OPEN_WIDTH : mx.controls.MediaController.MINIMUM_HORIZONTAL_WIDTH;
  468.       return _loc2_;
  469.    }
  470.    function getMinimumClosedWidth()
  471.    {
  472.       var _loc2_ = !this._horizontal ? mx.controls.MediaController.CLOSED_VERTICAL_WIDTH : mx.controls.MediaController.MINIMUM_HORIZONTAL_WIDTH;
  473.       return _loc2_;
  474.    }
  475.    function get controllerPolicy()
  476.    {
  477.       return this._controllerPolicy;
  478.    }
  479.    function set controllerPolicy(aPolicy)
  480.    {
  481.       mx.controls.streamingmedia.Tracer.trace("MediaController.set controllerPolicy: old=" + this._controllerPolicy + ", new=" + aPolicy);
  482.       if(aPolicy == this._controllerPolicy)
  483.       {
  484.          return;
  485.       }
  486.       this._controllerPolicy = aPolicy;
  487.       if(this._controllerPolicy == "on")
  488.       {
  489.          Mouse.removeListener(this);
  490.          if(!this._isOpen)
  491.          {
  492.             this.expand(true);
  493.          }
  494.       }
  495.       else if(this._controllerPolicy == "off")
  496.       {
  497.          Mouse.removeListener(this);
  498.          if(this._isOpen)
  499.          {
  500.             mx.controls.streamingmedia.Tracer.trace("MediaController.set controllerPolicy(off): about to call contract");
  501.             this.contract(true);
  502.          }
  503.       }
  504.       else
  505.       {
  506.          if(this._controllerPolicy != "auto")
  507.          {
  508.             throw new Error("The controller policy must be set to on, off, or auto");
  509.          }
  510.          this._closeId = null;
  511.          this._openId = null;
  512.          Mouse.addListener(this);
  513.          var _loc3_ = this.hitTest(_root._xmouse,_root._ymouse,true);
  514.          if(this._isOpen && !_loc3_)
  515.          {
  516.             mx.controls.streamingmedia.Tracer.trace("MediaController.set controllerPolicy(auto): about to call contract");
  517.             this.contract();
  518.          }
  519.          else if(!this._isOpen && _loc3_)
  520.          {
  521.             this.expand();
  522.          }
  523.       }
  524.    }
  525.    function get horizontal()
  526.    {
  527.       return this._horizontal;
  528.    }
  529.    function set horizontal(isHoriz)
  530.    {
  531.       if(isHoriz != this._horizontal)
  532.       {
  533.          this._horizontal = isHoriz;
  534.          var _loc2_ = this.height;
  535.          var _loc3_ = this.width;
  536.          if(isHoriz)
  537.          {
  538.             _loc2_ = Math.max(_loc2_,mx.controls.MediaController.MINIMUM_HORIZONTAL_WIDTH);
  539.             _loc3_ = Math.max(_loc3_,mx.controls.MediaController.MINIMUM_HORIZONTAL_OPEN_HEIGHT);
  540.          }
  541.          else
  542.          {
  543.             _loc2_ = Math.max(_loc2_,mx.controls.MediaController.MINIMUM_VERTICAL_OPEN_WIDTH);
  544.             _loc3_ = Math.max(_loc3_,mx.controls.MediaController.MINIMUM_VERTICAL_HEIGHT);
  545.          }
  546.          this.setSize(_loc2_,_loc3_);
  547.          this.invalidate();
  548.       }
  549.       else
  550.       {
  551.          this._horizontal = isHoriz;
  552.       }
  553.    }
  554.    function get volume()
  555.    {
  556.       return this._volume;
  557.    }
  558.    function set volume(vol)
  559.    {
  560.       this._volume = vol;
  561.       this._volumeControl.getHandle().setVolume(vol);
  562.    }
  563.    function get backgroundStyle()
  564.    {
  565.       return this._backgroundStyle;
  566.    }
  567.    function set backgroundStyle(aStyle)
  568.    {
  569.       this._backgroundStyle = aStyle;
  570.       this.drawChrome();
  571.    }
  572.    function broadcastEvent(eventType, detailArg)
  573.    {
  574.       var _loc2_ = {type:eventType,target:this,detail:detailArg};
  575.       if(eventType == "volume")
  576.       {
  577.          this._volume = detailArg;
  578.       }
  579.       this.dispatchEvent(_loc2_);
  580.    }
  581.    function handleEvent(ev)
  582.    {
  583.       if(ev.type == "change")
  584.       {
  585.          this.playAtBeginning = false;
  586.          if(this.isListeningForPlayheadMoveEvent())
  587.          {
  588.             this.handleChangeEvent(ev);
  589.          }
  590.       }
  591.       else if(ev.type == "progress")
  592.       {
  593.          this.handleProgressEvent(ev);
  594.       }
  595.       else if(ev.type == "complete")
  596.       {
  597.          this.handleCompleteEvent(ev);
  598.       }
  599.       else
  600.       {
  601.          this.handleUnrecognizedEvent(ev);
  602.       }
  603.    }
  604.    function isListeningForPlayheadMoveEvent()
  605.    {
  606.       return this._listenForPlayheadMoveEvent;
  607.    }
  608.    function setListeningForPlayheadMoveEvent(listen)
  609.    {
  610.       this._listenForPlayheadMoveEvent = listen;
  611.    }
  612.    function isNotAnimating()
  613.    {
  614.       return this._notAnimating;
  615.    }
  616.    function setNotAnimating(still)
  617.    {
  618.       this._notAnimating = still;
  619.    }
  620.    function get activePlayControl()
  621.    {
  622.       return this._activePlayControl;
  623.    }
  624.    function set activePlayControl(aControl)
  625.    {
  626.       this._activePlayControl = aControl;
  627.    }
  628.    function isPlaying()
  629.    {
  630.       return this._isPlaying;
  631.    }
  632.    function setPlaying(playFlag)
  633.    {
  634.       this._isPlaying = playFlag;
  635.       this._playBar.setIsPlaying(playFlag);
  636.       if(playFlag)
  637.       {
  638.          this._buttons.playPauseButtons.showPauseButton();
  639.       }
  640.       else
  641.       {
  642.          this._buttons.playPauseButtons.showPlayButton();
  643.       }
  644.    }
  645.    function handleChangeEvent(ev)
  646.    {
  647.       var _loc2_ = ev.target;
  648.       this._playTime = _loc2_.playheadTime;
  649.       var _loc3_ = _loc2_.totalTime;
  650.       this._playPercent = 100 * this._playTime / _loc3_;
  651.       if(this._isOpen)
  652.       {
  653.          this._playBar.setCompletionPercentage(this._playPercent);
  654.          this._playBar.setTime(this._playTime);
  655.       }
  656.       else
  657.       {
  658.          this._miniPlayBar.setCompletionPercentage(this._playPercent);
  659.       }
  660.    }
  661.    function handleProgressEvent(ev)
  662.    {
  663.       var _loc2_ = ev.target;
  664.       var _loc3_ = _loc2_.bytesLoaded;
  665.       var _loc4_ = _loc2_.bytesTotal;
  666.       this._loadPercent = 100 * _loc3_ / _loc4_;
  667.       this.refreshBars();
  668.       this._lastProgressMediaType = _loc2_.mediaType;
  669.       this.evaluateToEnd();
  670.    }
  671.    function evaluateToEnd()
  672.    {
  673.       if(!this._isOpen)
  674.       {
  675.          return undefined;
  676.       }
  677.       var _loc2_ = false;
  678.       if(this._loadPercent >= 99 && this.enabled)
  679.       {
  680.          if(this._lastProgressMediaType == "MP3")
  681.          {
  682.             _loc2_ = true;
  683.          }
  684.          else if(this._lastProgressMediaType == "FLV" && !mx.controls.streamingmedia.StreamingMediaConstants.DISABLE_FLV_TOEND)
  685.          {
  686.             _loc2_ = true;
  687.          }
  688.       }
  689.       this._buttons.toEndButton.enabled = _loc2_;
  690.    }
  691.    function handleCompleteEvent(ev)
  692.    {
  693.       if(!this.isScrubbing() && !this._animating)
  694.       {
  695.          var _loc2_ = ev.target;
  696.          this._playTime = _loc2_.totalTime;
  697.          this._playPercent = 100;
  698.          if(this._isOpen)
  699.          {
  700.             this._playBar.setCompletionPercentage(this._playPercent);
  701.             this._playBar.setTime(this._playTime);
  702.          }
  703.          else
  704.          {
  705.             this._miniPlayBar.setCompletionPercentage(this._playPercent);
  706.          }
  707.          this.setPlaying(false);
  708.          mx.controls.streamingmedia.Tracer.trace("MediaController.handleCompleteEvent: playAtBeginning=true");
  709.          this.playAtBeginning = true;
  710.       }
  711.    }
  712.    function handleUnrecognizedEvent(ev)
  713.    {
  714.       mx.controls.streamingmedia.Tracer.trace("received an unrecognized event of type " + ev.type + " with target " + ev.target);
  715.    }
  716.    function createDefaultStrings()
  717.    {
  718.       this._strings = new Object();
  719.       this._strings.paused = "PAUSED";
  720.       this._strings.streaming = "STREAMING";
  721.    }
  722.    function getLocalizedString(id)
  723.    {
  724.       var _loc2_ = this._strings[id];
  725.       return _loc2_;
  726.    }
  727.    function get playTime()
  728.    {
  729.       return this._playTime;
  730.    }
  731.    function set playTime(aTime)
  732.    {
  733.       this._playTime = aTime;
  734.    }
  735.    function get playPercent()
  736.    {
  737.       return this._playPercent;
  738.    }
  739.    function set playPercent(aPercent)
  740.    {
  741.       this._playPercent = aPercent;
  742.    }
  743.    function isOpenUpOrLeft()
  744.    {
  745.       return this._openUpOrLeft;
  746.    }
  747.    function setOpenUpOrLeft(is)
  748.    {
  749.       this._openUpOrLeft = is;
  750.    }
  751.    function associateDisplay(d)
  752.    {
  753.       d.associateController(this);
  754.    }
  755.    function setSize(w, h, noEvent)
  756.    {
  757.       super.setSize(w,h,noEvent);
  758.       this.invalidate();
  759.    }
  760.    function get enabled()
  761.    {
  762.       return this._enabled;
  763.    }
  764.    function set enabled(is)
  765.    {
  766.       mx.controls.streamingmedia.Tracer.trace("MediaController.set enabled to " + is);
  767.       this._enabled = is;
  768.       this._buttons.toStartButton.enabled = is;
  769.       this._buttons.toEndButton.enabled = is;
  770.       this._buttons.playPauseButtons.enabled = is;
  771.       this._volumeControl._muteButton.muteSimpleButton.enabled = is;
  772.       this._volumeControl._loudButton.loudSimpleButton.enabled = is;
  773.       this._playBar.enabled = is;
  774.       this._volumeControl.getHandle().enabled = is;
  775.       if(is)
  776.       {
  777.          if(this._priorPolicy != null)
  778.          {
  779.             this.controllerPolicy = this._priorPolicy;
  780.          }
  781.       }
  782.       else
  783.       {
  784.          this._priorPolicy = this.controllerPolicy;
  785.          if(this.controllerPolicy == "auto")
  786.          {
  787.             this.controllerPolicy = "off";
  788.          }
  789.       }
  790.    }
  791.    function isScrubbing()
  792.    {
  793.       return this._playBar.isScrubbing();
  794.    }
  795. }
  796.