as2 help
- Started
- Last post
- 5 Responses
- moogchild
so I have this mp3 player and everything is working ace except that I want to disable the auto play function on it. I've combed over it and can't figure it out. any help will be greatly appreciated!
Thanks!
function below._global.playerRoot = this;
soundObjNum = 0;function soundNav (success) {
trace (soundXML);
rootNode = soundXML.firstChild;
if (success) {
for (i=0; i<rootNode.childNodes.length; i++) { // node = rootNode.childNodes[i]; soundURL = node.attributes.soundURL; trace (i + " - " + soundURL); } } else { //bad trace ("xml load failure"); } } // function createSongNav () { rootNode = soundXML.firstChild; initY = 361; for (i=0; i<rootNode.childNodes.length; i++) { // node = rootNode.childNodes[i]; //trace (i + " - " + soundURL); item = this.attachMovie ("soundClip", "soundItem" + i, i); item.soundURL = node.attributes.soundURL; item.artistName = node.attributes.artistName; item.albumName = node.attributes.albumName; item.songName = node.attributes.songName; item.soundTitle = item.songName; item.id = i; // item._x = 485; item._y = initY + (i * item._height + 3); // item.bg.onRelease = this.mouseClick; item.bg.callBack = this; } _global.playerRoot.currentSong = this["soundItem" + 0]; } // function mouseClick () { autoClick (); trace (_global.playerRoot["soundObj" + (_global.playerRoot.soundObjNum - 1)]); _global.playerRoot["soundObj" + (_global.playerRoot.soundObjNum - 1)].loadSound (this._parent.soundURL, true); _global.playerRoot.soundHost.don... = false; _global.playerRoot.displaySongDa... (this._parent); _global.playerRoot.soundHost.pro... = 0; _global.playerRoot.soundHost.son... = 0; _global.playerRoot.soundHost.pla... = false; _global.playerRoot.soundHost.pla... = 0; _global.playerRoot.currentSong = this._parent; _global.soundAction = "play"; } // // function autoClick () { trace ("auto click"); trace (_global.playerRoot.currentSong... if (_global.playerRoot["soundObj" + _global.playerRoot.soundObjNum] == undefined) { if (_global.playerRoot.soundObjNum != 0) { _global.playerRoot["soundObj" + (_global.playerRoot.soundObjNum - 1)] = undefined; } _global.playerRoot["soundObj" + _global.playerRoot.soundObjNum] = new Sound(); _global.playerRoot.soundObjNum += 1; } _global.playerRoot["soundObj" + (_global.playerRoot.soundObjNum - 1)].onLoad = function (success) { if (success == true) { trace ("ok!"); } else { trace ("load failure"); } } songNum = rootNode.childNodes.length - 1; if (_global.playerRoot.currentSong... >= songNum) {
_global.playerRoot.currentSong = _global.playerRoot["soundItem" + 0];
_global.playerRoot["soundObj" + (_global.playerRoot.soundObjNum - 1)].loadSound (_global.playerRoot.currentSong... true);
} else {
_global.playerRoot.currentSong = _global.playerRoot["soundItem" + (_global.playerRoot.currentSong... + 1)];
_global.playerRoot["soundObj" + (_global.playerRoot.soundObjNum - 1)].loadSound (_global.playerRoot.currentSong... true);
}
trace ("loading: " + _global.playerRoot.currentSong.s...
//
_global.playerRoot.soundHost.don... = false;
_global.playerRoot.displaySongDa... (_global.playerRoot.currentSong...
_global.playerRoot.soundHost.pro... = 0;
_global.playerRoot.soundHost.son... = 0;
_global.playerRoot.soundHost.pla... = false;
_global.playerRoot.soundHost.pla... = 0;
_global.soundAction = "play";
}
//
function displaySongData (item) {
trace (item);
_global.playerRoot.soundHost.art... = "FEATURING: " + item.artistName;
_global.playerRoot.soundHost.alb... = "" + item.albumName;
_global.playerRoot.soundHost.son... = "SONG: " + item.songName;
}
//
function preload (theSound) {
total_bytes = theSound.getBytesTotal();
bytes = theSound.getBytesLoaded();
percentRatio = bytes/total_bytes;
percentage = Math.round((percentRatio) * 100);
//
if (bytes == total_bytes) {
_global.playerRoot.soundHost.per... = percentage;
_global.playerRoot.soundHost.pro... = percentRatio * _global.playerRoot.soundHost.pro...
//theSound.start();
//clearInterval(intID);
_global.playerRoot.soundHost.don... = true;
} else {
if (total_bytes > 0) {
_global.playerRoot.soundHost.per... = percentage;
_global.playerRoot.soundHost.pro... = percentRatio * _global.playerRoot.soundHost.pro...
} else {
_global.playerRoot.soundHost.per... = 0;
}
}
}
function checkDuration () {
soundObject = _global.playerRoot["soundObj" + (_global.playerRoot.soundObjNum - 1)];
if (_global.soundAction == "play") {
if (_global.playerRoot.soundHost.pl... == false) {
soundDuration = soundObject.duration;
soundPos = soundObject.position;
//
soundPercent = soundPos/soundDuration;
//
seconds = Math.round(soundPos/1000);
minutes = Math.floor(seconds/60);
displaySeconds = Math.round(seconds - (minutes * (seconds/60)));
//
_global.playerRoot.soundHost.sou... = minutes + " : " + displaySeconds;
_global.playerRoot.soundHost.pla... = soundPercent * _global.playerRoot.soundHost.pro...
_global.playerRoot.soundHost.son... = soundPercent * _global.playerRoot.soundHost.pro...
if (soundPos > 5 && soundDuration == soundPos) {
_global.playerRoot.autoClick();
}
} else {
_global.playerRoot.soundHost.son... = _global.playerRoot.soundHost.pla...
}
} else if (_global.soundAction == "pause") {
//
} else {
//
}
}function movedPlayhead() {
soundObject = _global.playerRoot["soundObj" + (_global.playerRoot.soundObjNum - 1)];
playHeadPos = _global.playerRoot.soundHost.pla...
soundDuration = soundObject.duration;
//soundPos = soundObj.position;
secOffset = (soundDuration * playHeadPos)/1000;
soundObject.stop();
soundObject.start(secOffset, 1);
_global.playerRoot.soundHost.pla... = false;
}function pausePlayStop(action, clip) {
soundObject = _global.playerRoot["soundObj" + (_global.playerRoot.soundObjNum - 1)];
if (action == "play") {
soundObject.start(_global.paused... 1);
_global.soundAction = "play";
clip.gotoAndStop(1);
} else if (action == "pause") {// pause functions
// first get current sound position in seconds
soundPos = soundObject.position;
seconds = Math.round(soundPos/1000);
// then stop sound
soundObject.stop();
_global.pausedPos = seconds;
_global.soundAction = "pause";
clip.gotoAndStop(2);
} else {
_global.pausedPos = 0;
_global.playerRoot.soundHost.son... = 0;
_global.playerRoot.soundHost.pla... = 0;
soundObject.stop();
_global.pausedPos = 0;
_global.soundAction = "stop";
_global.playerRoot.soundHost.sou... = "0 : 0";
_global.playerRoot.soundHost.pla... = 0;
_global.playerRoot.soundHost.son... = 0;
clip.gotoAndStop(2);
}
}function fastForward () {
ffSpeed = 3;//in seconds
soundObject = _global.playerRoot["soundObj" + (_global.playerRoot.soundObjNum - 1)];
soundDuration = soundObject.duration;
soundPos = soundObject.position;
ffPos = (soundPos/1000) + ffSpeed;
trace ("soundPercent: " + soundPercent);
if (_global.soundAction == "pause") {
soundObject.stop();
soundPercent = ((_global.pausedPos + ffSpeed) * 1000)/soundDuration;
_global.playerRoot.soundHost.pla... = soundPercent * _global.playerRoot.soundHost.pro...
_global.playerRoot.soundHost.son... = _global.playerRoot.soundHost.pla...
_global.pausedPos = _global.pausedPos + ffSpeed;
} else if (_global.soundAction == "stop") {
soundObject.stop();
soundPercent = ((_global.pausedPos + ffSpeed) * 1000)/soundDuration;
_global.playerRoot.soundHost.pla... = soundPercent * _global.playerRoot.soundHost.pro...
_global.playerRoot.soundHost.son... = _global.playerRoot.soundHost.pla...
_global.pausedPos = _global.pausedPos + ffSpeed;
} else {
soundObject.stop();
soundObject.start(ffPos, 1);
}
}
function rewindSound () {
revSpeed = 3;//in seconds
soundObject = _global.playerRoot["soundObj" + (_global.playerRoot.soundObjNum - 1)];
soundDuration = soundObject.duration;
soundPos = soundObject.position;
revPos = (soundPos/1000) - revSpeed;
//trace ("revPos: " + revPos);
if (_global.soundAction == "pause") {
soundObject.stop();
soundPercent = ((_global.pausedPos - revSpeed) * 1000)/soundDuration;
_global.playerRoot.soundHost.pla... = soundPercent * _global.playerRoot.soundHost.pro...
_global.playerRoot.soundHost.son... = _global.playerRoot.soundHost.pla...
_global.pausedPos = _global.pausedPos - revSpeed;
} else if (_global.soundAction == "stop") {
soundObject.stop();
soundPercent = ((_global.pausedPos + ffSpeed) * 1000)/soundDuration;
_global.playerRoot.soundHost.pla... = soundPercent * _global.playerRoot.soundHost.pro...
_global.playerRoot.soundHost.son... = _global.playerRoot.soundHost.pla...
_global.pausedPos = _global.pausedPos + ffSpeed;
} else {
soundObject.stop();
soundObject.start(revPos, 1);
}
}
- GeorgesII0
paste your code here,
http://pastebin.com/
- acescence0
doesn't look like it's in there. there's something elsewhere calling the functions to load the xml, build the song nav, and play
- fyoucher10
line 99 in autoClick() function, last line of code in function.
_global.soundAction = "play";...
Change it to "pause".- I am in awe of you guys!alicetheblue
- I could totally be wrong. Or not.fyoucher1
- smart, i think that would do it.acescence
- moogchild0
I got it, there was a "autoClick" buried in there. Thanks for having a look though and if you're ever in the EV,NYC give me a holla and we'll go grab a bottle of suds. ;)