Frame 1
SoundManager2.main(this);
Symbol 20480 MovieClip [__Packages.SoundManager2] Frame 0
class SoundManager2
{
static var app;
function SoundManager2 () {
var version = "V2.97a.20120624";
var version_as = "(AS2/Flash 8)";
var _local2 = false;
var _local3 = "*";
if (_local2 && (_local3)) {
System.security.allowDomain(_local3);
version_as = version_as + " - cross-domain enabled";
}
var baseJSController = "soundManager";
var baseJSObject = (baseJSController + ".sounds");
var sounds = [];
var soundObjects = [];
var timer = null;
var pollingEnabled = false;
var debugEnabled = true;
var flashDebugEnabled = false;
var didSandboxMessage = false;
var caughtFatal = false;
var _messages = [];
var _messageObj = null;
flashDebugEnabled = _root.debug == 1;
Stage.scaleMode = "noScale";
Stage.align = "TL";
var _local4 = function () {
};
var _local5 = new ContextMenu();
var _local6 = new ContextMenuItem((("SoundManager " + version) + " ") + version_as, _local4);
_local6.enabled = false;
_local5.customItems.push(_local6);
_root.menu = _local5;
var writeDebug = function (s) {
if (!debugEnabled) {
return(false);
}
flash.external.ExternalInterface.call(baseJSController + "['_writeDebug']", "(Flash): " + s);
};
var flashDebug = function (messageText) {
_messages.push(messageText);
if (!flashDebugEnabled) {
return(false);
}
var _local3 = new TextFormat();
_local3.size = 12;
_local3.font = "Arial";
var _local4 = (Stage.width ? (Stage.width) : 320);
var _local5 = (Stage.height ? (Stage.height) : 240);
if (!_messageObj) {
_messageObj = _root.createTextField("_messageObj", 0, 0, 0, _local4, _local5);
_messageObj.x = 0;
_messageObj.y = 0;
_messageObj.multiline = true;
_messageObj.html = true;
_messageObj.wordWrap = true;
_messageObj.align = "left";
_messageObj.autoSize = false;
}
_messageObj.htmlText = _messages.join(newline);
_messageObj.setTextFormat(_local3);
_messageObj.width = _local4;
_messageObj.height = _local5;
};
var _externalInterfaceTest = function (isFirstCall) {
var _local3 = System.security.sandboxType;
try {
if (isFirstCall) {
flashDebug("Testing Flash -> JS...");
if ((!didSandboxMessage) && ((_local3 != "remote") && (_local3 != "localTrusted"))) {
didSandboxMessage = true;
flashDebug(("<br><b>Fatal: Security sandbox error: Got \"" + _local3) + "\", expected \"remote\" or \"localTrusted\".<br>Additional security permissions need to be granted.<br>See <a href=\"http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html\">flash security settings panel</a> for non-HTTP, eg. file:// use.</b><br>http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html<br><br>You may also be able to right-click this movie and choose from the menu: <br>\"Global Settings\" -> \"Advanced\" tab -> \"Trusted Location Settings\"<br>");
}
var _local4 = new Date();
flash.external.ExternalInterface.call(baseJSController + "._externalInterfaceOK", _local4.getTime(), version);
if (!didSandboxMessage) {
flashDebug("Flash -> JS OK");
flashDebug("Waiting for JS -> Flash...");
}
} else {
writeDebug((("SM2 SWF " + version) + " ") + version_as);
flashDebug("JS -> Flash OK");
writeDebug("JS to/from Flash OK");
flash.external.ExternalInterface.call(baseJSController + "._setSandboxType", _local3);
}
} catch(_local) {
var e = ( /* Error999 */
);
flashDebug(e.toString());
if (!caughtFatal) {
caughtFatal = true;
}
return(false);
}
return(true);
};
var _disableDebug = function () {
writeDebug("_disableDebug()");
debugEnabled = false;
};
var checkProgress = function () {
var _local2 = 0;
var _local3 = 0;
var _local4 = 0;
var _local5 = 0;
var _local6 = null;
var _local7 = 0;
var _local8 = sounds.length;
for ( ; _local7 < _local8 ; _local7++) {
_local6 = soundObjects[sounds[_local7]];
_local2 = _local6.getBytesLoaded();
_local3 = _local6.getBytesTotal();
_local4 = _local6.duration || 0;
_local5 = _local6.position;
if (_local2 && (_local3 && (_local2 != _local6.lastValues.bytes))) {
_local6.lastValues.bytes = _local2;
flash.external.ExternalInterface.call(((baseJSObject + "['") + _local6.sID) + "']._whileloading", _local2, _local3, _local4);
}
if ((typeof(_local5) != "undefined") && (_local5 != _local6.lastValues.position)) {
_local6.lastValues.position = _local5;
flash.external.ExternalInterface.call(((baseJSObject + "['") + _local6.sID) + "']._whileplaying", _local5);
}
}
};
var onLoad = function (bSuccess) {
checkProgress();
flash.external.ExternalInterface.call(((baseJSObject + "['") + this.sID) + "']._whileloading", this.getBytesLoaded(), this.getBytesTotal(), this.duration);
flash.external.ExternalInterface.call(((baseJSObject + "['") + this.sID) + "']._onload", ((this.duration > 0) ? 1 : 0));
};
var onID3 = function () {
var _local2 = [];
var _local3 = [];
for (var prop in this.id3) {
_local3.push(prop);
_local2.push(this.id3[prop]);
}
flash.external.ExternalInterface.call(((baseJSObject + "['") + this.sID) + "']._onid3", _local3, _local2);
soundObjects[this.sID].onID3 = null;
};
var registerOnComplete = function (sID) {
soundObjects[sID].onSoundComplete = function () {
checkProgress();
flash.external.ExternalInterface.call(((baseJSObject + "['") + sID) + "']._onfinish");
};
};
var _setPosition = function (sID, nSecOffset, isPaused, _allowMultiShot) {
var _local6 = soundObjects[sID];
_local6.lastValues.position = _local6.position;
if ((_local6.lastValues.loops > 1) && (nSecOffset != 0)) {
writeDebug("Warning: Looping functionality being disabled due to Flash limitation.");
_local6.lastValues.loops = 1;
}
_local6.start(nSecOffset, _local6.lastValues.nLoops || 1);
if (isPaused) {
_local6.stop();
}
};
var _load = function (sID, sURL, bStream, bAutoPlay, bCheckPolicyFile) {
if (typeof(bAutoPlay) == "undefined") {
bAutoPlay = false;
}
if (typeof(bStream) == "undefined") {
bStream = true;
}
if (typeof(bCheckPolicyFile) == "undefined") {
bCheckPolicyFile = false;
}
var _local7 = soundObjects[sID];
_local7.onID3 = onID3;
_local7.onLoad = onLoad;
_local7.loaded = true;
_local7.checkPolicyFile = bCheckPolicyFile;
_local7.loadSound(sURL, bStream);
if (bAutoPlay != true) {
_local7.stop();
} else {
writeDebug("auto-play allowed");
}
registerOnComplete(sID);
};
var _unload = function (sID, sURL) {
var _local4 = soundObjects[sID];
_local4.onID3 = null;
_local4.onLoad = null;
_local4.loaded = false;
_local4.start(0, 1);
_local4.stop();
_local4.loadSound(sURL, true);
_local4.stop();
};
var _createSound = function (sID, loops, checkPolicyFile) {
var _local5 = new Sound();
if (!soundObjects[sID]) {
sounds.push(sID);
}
soundObjects[sID] = _local5;
_local5.setVolume(100);
_local5.sID = sID;
_local5.paused = false;
_local5.loaded = false;
_local5.checkPolicyFile = checkPolicyFile;
_local5.lastValues = {bytes:0, position:0, nLoops:loops || 1};
};
var _destroySound = function (sID) {
var _local3 = soundObjects[sID] || null;
if (!_local3) {
return(false);
}
var _local4 = 0;
for ( ; _local4 < sounds.length ; _local4++) {
if (sounds[_local4] == sID) {
sounds.splice(_local4, 1);
break;
}
}
_local3 = null;
delete soundObjects[sID];
};
var _stop = function (sID, bStopAll) {
if (bStopAll) {
_root.stop();
} else {
soundObjects[sID].stop();
soundObjects[sID].paused = false;
}
};
var _start = function (sID, nLoops, nMsecOffset, _allowMultiShot) {
registerOnComplete();
var _local6 = soundObjects[sID];
_local6.lastValues.paused = false;
_local6.lastValues.nLoops = nLoops || 1;
_local6.start(nMsecOffset, nLoops);
return(true);
};
var _pause = function (sID, _allowMultiShot) {
var _local4 = soundObjects[sID];
if (!_local4.paused) {
_local4.paused = true;
_local4.lastValues.position = _local4.position;
_local4.stop();
} else {
_local4.paused = false;
_local4.start(_local4.lastValues.position / 1000, _local4.lastValues.nLoops);
}
};
var _setPan = function (sID, nPan) {
soundObjects[sID].setPan(nPan);
};
var _setVolume = function (sID, nVol) {
soundObjects[sID].setVolume(nVol);
};
var _setPolling = function (bPolling, timerInterval) {
if (typeof(timerInterval) === "undefined") {
timerInterval = 50;
}
pollingEnabled = bPolling;
if ((timer == null) && (pollingEnabled)) {
writeDebug(("Enabling polling, " + timerInterval) + " ms interval");
timer = _global.setInterval(checkProgress, timerInterval);
} else if (timer && (!pollingEnabled)) {
writeDebug("Disabling polling");
_global.clearInterval(timer);
timer = null;
}
};
var _local7 = function () {
try {
flashDebug("Adding ExternalInterface callbacks...");
flash.external.ExternalInterface.addCallback("_load", this, _load);
flash.external.ExternalInterface.addCallback("_unload", this, _unload);
flash.external.ExternalInterface.addCallback("_stop", this, _stop);
flash.external.ExternalInterface.addCallback("_start", this, _start);
flash.external.ExternalInterface.addCallback("_pause", this, _pause);
flash.external.ExternalInterface.addCallback("_setPosition", this, _setPosition);
flash.external.ExternalInterface.addCallback("_setPan", this, _setPan);
flash.external.ExternalInterface.addCallback("_setVolume", this, _setVolume);
flash.external.ExternalInterface.addCallback("_setPolling", this, _setPolling);
flash.external.ExternalInterface.addCallback("_externalInterfaceTest", this, _externalInterfaceTest);
flash.external.ExternalInterface.addCallback("_disableDebug", this, _disableDebug);
flash.external.ExternalInterface.addCallback("_createSound", this, _createSound);
flash.external.ExternalInterface.addCallback("_destroySound", this, _destroySound);
} catch(_local) {
var e = ( /* Error999 */
);
flashDebug("Fatal: ExternalInterface error: " + e.toString());
}
_externalInterfaceTest(true);
};
flashDebug((("SM2 SWF " + version) + " ") + version_as);
if (flash.external.ExternalInterface.available) {
flashDebug("ExternalInterface available");
_local7();
} else {
flashDebug("Fatal: ExternalInterface (Flash <-> JS) not available");
}
}
static function main(mc) {
app = new SoundManager2();
}
//ASSetPropFlags(_local1, null, 1);
}