//Sprite 24
// Frame 0
// Action tag #0
function loadProgress()
{
var __reg1 = sndObject.getBytesLoaded() / sndObject.getBytesTotal();
percentBar._width = __reg1 * barWidth;
if (__reg1 == 1)
{
clearInterval(loadProgressInt);
}
}
function playProgress()
{
var __reg1 = sndObject.position / sndObject.duration * sndObject.getBytesLoaded() / sndObject.getBytesTotal();
progressBar._width = __reg1 * barWidth;
}
function scrubProgress()
{
var __reg1 = percentBar._xmouse * percentBar._xscale / 100;
if (__reg1 > percentBar._width)
{
__reg1 = percentBar._width;
}
progressBar._width = __reg1;
var __reg2 = __reg1 / barWidth;
pausePos = __reg2 * sndObject.duration / 1000;
}
function playSong()
{
if (pausePos == 0)
{
sndObject.setVolume(songVolume);
sndObject.loadSound(file, true);
loadProgressInt = setInterval(loadProgress, 50);
}
sndObject.start(pausePos);
playProgressInt = setInterval(playProgress, 50);
pauseBut._visible = true;
playBut._visible = false;
}
function pauseSong(p)
{
if (p)
{
pausePos = p;
}
else
{
pausePos = sndObject.position / 1000;
}
sndObject.stop();
pauseBut._visible = false;
playBut._visible = true;
clearInterval(playProgressInt);
}
if (_root.file)
{
var file = _root.file;
}
else
{
var file = "sound.mp3";
}
if (_root.showDownload)
{
var showDownload = _root.showDownload;
}
else
{
var showDownload = "true";
}
if (_root.autoStart)
{
var autoStart = _root.autoStart;
}
else
{
var autoStart = "false";
}
if (_root.repeatPlay)
{
var repeatPlay = _root.repeatPlay;
}
else
{
var repeatPlay = "false";
}
if (_root.songVolume)
{
var songVolume = int(_root.songVolume);
}
else
{
var songVolume = 90;
}
if (_root.backColor)
{
var backColor = "0x" + _root.backColor;
}
else
{
var backColor = "0xeeeeee";
}
if (_root.frontColor)
{
var frontColor = "0x" + _root.frontColor;
}
else
{
var frontColor = "0x333333";
}
var w = Stage.width;
var sndObject = new Sound();
var pausePos = 0;
var loadProgressInt = new Number();
var playProgressInt = new Number();
var scrubProgressInt = new Number();
pauseBut.onPress = function ()
{
pauseSong();
}
;
playBut.onPress = function ()
{
playSong();
}
;
percentBar.onPress = function ()
{
pauseSong();
scrubProgressInt = setInterval(scrubProgress, 50);
}
;
percentBar.onRelease = percentBar.onReleaseOutside = function ()
{
clearInterval(scrubProgressInt);
playSong();
}
;
sndObject.onSoundComplete = function ()
{
if (repeatPlay == "true")
{
pausePos = 0.001;
playSong();
return;
}
progressBar._width = 0.1;
pauseSong(0.001);
}
;
var listener = new Object();
listener.onSelect = function (file)
{
trace("onSelect: " + file.name);
}
;
listener.onCancel = function (file)
{
trace("onCancel");
}
;
listener.onOpen = function (file)
{
trace("onOpen: " + file.name);
}
;
listener.onProgress = function (file, bytesLoaded, bytesTotal)
{
trace("onProgress with bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal);
}
;
listener.onComplete = function (file)
{
trace("onComplete: " + file.name);
}
;
listener.onIOError = function (file)
{
trace("onIOError: " + file.name);
}
;
var fileRef = new flash.net.FileReference();
fileRef.addListener(listener);
saveBut.onPress = function ()
{
var __reg1 = file.substr(file.lastIndexOf("/") + 1);
fileRef.download(file, __reg1);
trace(__reg1);
}
;
var leftBgColor = new Color(leftBg);
var centerBgColor = new Color(centerBg);
var rightBgColor = new Color(rightBg);
leftBgColor.setRGB(int(backColor));
centerBgColor.setRGB(int(backColor));
rightBgColor.setRGB(int(backColor));
var playButColor = new Color(playBut);
var pauseButColor = new Color(pauseBut);
var percentBarColor = new Color(percentBar);
var progressBarColor = new Color(progressBar);
var saveButColor = new Color(saveBut);
playButColor.setRGB(int(frontColor));
pauseButColor.setRGB(int(frontColor));
percentBarColor.setRGB(int(frontColor));
progressBarColor.setRGB(int(frontColor));
saveButColor.setRGB(int(frontColor));
leftBg._x = leftGlow._x = 0;
centerBg._x = centerGlow._x = 7;
centerBg._width = centerGlow._width = w - 14;
rightBg._x = rightGlow._x = w - 7;
playBut._x = pauseBut._x = 12;
percentBar._x = progressBar._x = 21;
if (showDownload == "true")
{
var barWidth = percentBar._width = progressBar._width = w - 45;
saveBut._x = w - 17;
}
else
{
var barWidth = percentBar._width = progressBar._width = w - 32;
}
percentBar._alpha = 50;
pauseBut._visible = false;
progressBar._width = percentBar._width = 0;
if (w <= 35 || showDownload == "false")
{
saveBut._visible = false;
}
if (w <= 60)
{
percentBar._visible = progressBar._visible = false;
}
if (autoStart == "true")
{
playSong();
}