home *** CD-ROM | disk | FTP | other *** search
- class mx.controls.streamingmedia.LoadBar extends MovieClip
- {
- var _controller;
- var _fill;
- var _border;
- var _background;
- function LoadBar()
- {
- super();
- this.init();
- }
- function init()
- {
- this._controller = this._parent;
- this.draw();
- }
- function isVertical()
- {
- return !this._controller.horizontal;
- }
- function getCompletionPercentage()
- {
- var _loc2_ = undefined;
- if(this.isVertical())
- {
- _loc2_ = this.yToPercent(this._fill._height);
- }
- else
- {
- _loc2_ = this.xToPercent(this._fill._width);
- }
- return _loc2_;
- }
- function setCompletionPercentage(aPercentage)
- {
- aPercentage = Math.floor(aPercentage);
- if(aPercentage < 0)
- {
- aPercentage = 0;
- }
- else if(aPercentage > 100)
- {
- aPercentage = 100;
- }
- if(this.isVertical())
- {
- this._fill._height = this.percentToY(aPercentage);
- this._fill._y = this.getActualHeight() - this._fill._height - 1;
- }
- else
- {
- this._fill._width = this.percentToX(aPercentage);
- }
- }
- function draw(size)
- {
- var _loc3_ = this.getCompletionPercentage();
- if(this.isVertical())
- {
- if(size == null)
- {
- size = this.getHeight();
- }
- this._y = 8;
- this._border._height = size;
- this._background._height = size - 2;
- }
- else
- {
- if(size == null)
- {
- size = this.getWidth();
- }
- this._x = 8;
- this._border._width = size;
- this._background._width = size - 2;
- }
- this.setCompletionPercentage(_loc3_);
- }
- function getWidth()
- {
- var _loc2_ = undefined;
- if(this.isVertical())
- {
- _loc2_ = 3;
- }
- else
- {
- _loc2_ = this._controller.width - 16;
- }
- return _loc2_;
- }
- function getHeight()
- {
- var _loc2_ = undefined;
- if(this.isVertical())
- {
- if(this._controller.expanded)
- {
- _loc2_ = this.getOpenHeight();
- }
- else
- {
- _loc2_ = this.getClosedHeight();
- }
- }
- else
- {
- _loc2_ = 3;
- }
- return _loc2_;
- }
- function getActualHeight()
- {
- return this._border._height;
- }
- function getActualWidth()
- {
- return this._border._width;
- }
- function getOpenHeight()
- {
- return this._controller.height - 90;
- }
- function getClosedHeight()
- {
- return this._controller.height - 16;
- }
- function xToPercent(x)
- {
- var _loc2_ = 100 * x / (this.getActualWidth() - 2);
- return _loc2_;
- }
- function percentToX(percent)
- {
- var _loc2_ = (this.getWidth() - 2) * (percent / 100);
- return _loc2_;
- }
- function yToPercent(y)
- {
- var _loc2_ = 100 * (y - 0) / (this.getActualHeight() - 2);
- return _loc2_;
- }
- function percentToY(percent)
- {
- var _loc2_ = (this.getActualHeight() - 2) * (percent / 100);
- return _loc2_;
- }
- }
-