home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
i·claim - visualizing argument
/
ICLAIM.ISO
/
mac
/
glossary.swf
/
scripts
/
__Packages
/
mx
/
controls
/
streamingmedia
/
PlayBar.as
< prev
next >
Wrap
Text File
|
2005-02-24
|
6KB
|
205 lines
class mx.controls.streamingmedia.PlayBar extends MovieClip
{
static var TEXT_ALPHA_DARK = 100;
static var TEXT_ALPHA_LIGHT = 50;
static var PULSE_DURATION = 1400;
static var ACTIVE_PULSE_PORTION = 0.4;
static var STREAMING_ID = "streaming";
static var PAUSED_ID = "paused";
function PlayBar()
{
super();
this.init();
}
function init()
{
this._controller = this._parent;
this.setCompletionPercentage(this._controller.__get__playPercent());
this.setTime(this._controller.__get__playTime());
this.draw();
}
function isVertical()
{
return !this._controller.__get__horizontal();
}
function getCompletionPercentage()
{
var _loc2_ = undefined;
if(this.isVertical())
{
_loc2_ = this.yToPercent(this._thumb._y);
}
else
{
_loc2_ = this.xToPercent(this._thumb._x);
}
return _loc2_;
}
function setCompletionPercentage(aPercentage)
{
aPercentage = Math.floor(aPercentage);
if(aPercentage < 1)
{
aPercentage = 1;
}
else if(aPercentage > 100)
{
aPercentage = 100;
}
if(this.isVertical())
{
var _loc3_ = this.percentToY(aPercentage);
this._thumb._y = this.getHeight() - _loc3_ - 9;
}
else
{
var _loc4_ = this.percentToX(aPercentage);
this._thumb._x = _loc4_;
}
this.updateHiliteToMatchThumb();
}
function updateHiliteToMatchThumb()
{
if(this.isVertical())
{
this._hilite._height = this.getHeight() - this._thumb._y - 6;
this._hilite._y = this.getHeight() - this._hilite._height - 1;
}
else
{
this._hilite._width = this._thumb._x + 4;
}
}
function setTime(aTime)
{
var _loc7_ = Math.floor(aTime / 3600);
var _loc3_ = aTime % 3600;
var _loc6_ = Math.floor(_loc3_ / 60);
_loc3_ %= 60;
var _loc5_ = Math.floor(_loc3_);
_loc3_ %= 1;
var _loc2_ = Math.round(_loc3_ * 1000);
var _loc4_ = _loc7_ + ":" + (_loc6_ >= 10 ? "" : "0") + _loc6_ + ":" + (_loc5_ >= 10 ? "" : "0") + _loc5_ + ".";
if(_loc2_ < 10)
{
_loc4_ += "00" + String(_loc2_);
}
else if(_loc2_ < 100)
{
_loc4_ += "0" + String(_loc2_);
}
else
{
_loc4_ += String(_loc2_);
}
this._timeTextField.text = _loc4_;
}
function setIsPlaying(isPlaying)
{
if(isPlaying)
{
this._statusTextField.text = this._controller.getLocalizedString(mx.controls.streamingmedia.PlayBar.STREAMING_ID);
delete this.onEnterFrame;
this.setDarkText();
}
else
{
this._statusTextField.text = this._controller.getLocalizedString(mx.controls.streamingmedia.PlayBar.PAUSED_ID);
this._darkenText = false;
this._textPulseTime = getTimer();
this.onEnterFrame = this.pulseText;
}
}
function getController()
{
return this._controller;
}
function draw()
{
var _loc2_ = this.getCompletionPercentage();
if(this.isVertical())
{
this._x = (this._controller.__get__width() - this.getWidth()) / 2;
this._y = 8;
this._tray.setHeight(this.getHeight());
this._statusTextField._y = this.getHeight() - 4;
}
else
{
this._x = 8;
this._tray.setWidth(this.getWidth());
this._timeTextField._x = this.getWidth() - this._timeTextField._width - 3;
}
this.setIsPlaying(this._controller.isPlaying());
this.setCompletionPercentage(_loc2_);
}
function getWidth()
{
var _loc2_ = !this.isVertical() ? this._controller.__get__width() - 16 : 20;
return _loc2_;
}
function getHeight()
{
var _loc2_ = !this.isVertical() ? 20 : this._controller.__get__height() - 90;
return _loc2_;
}
function xToPercent(x)
{
var _loc2_ = 100 * ((x + 3) / (this.getWidth() - 3));
return _loc2_;
}
function percentToX(percent)
{
var _loc2_ = (this.getWidth() - 3) * (percent / 100) - 3;
return _loc2_;
}
function yToPercent(y)
{
var _loc2_ = 100 * ((this.getHeight() - 3 - y) / this.getHeight());
return _loc2_;
}
function percentToY(percent)
{
var _loc2_ = (this.getHeight() - 3) * (percent / 100) - 3;
return _loc2_;
}
function pulseText()
{
var _loc2_ = getTimer() - this._textPulseTime;
var _loc5_ = Math.min(1,_loc2_ / mx.controls.streamingmedia.PlayBar.PULSE_DURATION);
var _loc7_ = mx.controls.streamingmedia.PlayBar.PULSE_DURATION * mx.controls.streamingmedia.PlayBar.ACTIVE_PULSE_PORTION;
var _loc6_ = Math.min(1,_loc2_ / _loc7_);
var _loc4_ = _loc6_ * (mx.controls.streamingmedia.PlayBar.TEXT_ALPHA_DARK - mx.controls.streamingmedia.PlayBar.TEXT_ALPHA_LIGHT);
var _loc3_ = !this._darkenText ? mx.controls.streamingmedia.PlayBar.TEXT_ALPHA_DARK - _loc4_ : mx.controls.streamingmedia.PlayBar.TEXT_ALPHA_LIGHT + _loc4_;
this._statusTextField._alpha = _loc3_;
this._timeTextField._alpha = _loc3_;
if(_loc5_ >= 1)
{
this._darkenText = !this._darkenText;
this._textPulseTime = getTimer();
}
}
function setDarkText()
{
this._statusTextField._alpha = mx.controls.streamingmedia.PlayBar.TEXT_ALPHA_DARK;
this._timeTextField._alpha = mx.controls.streamingmedia.PlayBar.TEXT_ALPHA_DARK;
}
function setLightText()
{
this._statusTextField._alpha = mx.controls.streamingmedia.PlayBar.TEXT_ALPHA_LIGHT;
this._timeTextField._alpha = mx.controls.streamingmedia.PlayBar.TEXT_ALPHA_LIGHT;
}
function get enabled()
{
return this._thumb.__get__enabled();
}
function set enabled(is)
{
this._thumb.__set__enabled(is);
}
function isScrubbing()
{
return this._thumb.isScrubbing();
}
}