ciao ragazzi, sto seguento un tutorial per fare un lettore mp3 che legga da xml ma non riesco a far funzionare il tasto next per richiamare il brano seguente qualcuno riesce a darmi una mano. dove sbaglio?
grazie!!
// setup sound object
var s:Sound = new Sound();
s.onSoundComplete = playSong;
s.setVolume(75);
// array of songs
var sa:Array = new Array();
// current playing song
var cps:Number = -1;
//Position of music
var pos:Number;
//load xml object
var xml:XML = new XML();
xml.ignoreWhite = true;
xml.onLoad = function() {
var nodes:Array = this.firstChild.childNodes;
for (var i = 0; i<nodes.length; i++) {
sa.push(nodes[i].attributes.url);
}
playSong();
}
xml.load('songs.xml');
// Play the mp3 file
function playSong():Void
{
s = new Sound();
if (cps == sa.length-1)
{
cps = 0;
s.loadSound(sa[cps], true);
} else {
s.loadSound(sa[++cps], true);
}
playPause.gotoAndStop('pause');
}
//pause the music
function pauseIt():Void {
pos = s.position;
s.stop();
}
//unPause the music
function unPauseIt():Void
{
s.start(pos/1000);
}
//music controls
//Play Pause
playPause.onRollOver = function()
{
if (this._currentframe == 1) this.gotoAndStop('pauseOver');
else this.gotoAndStop('playOver');
}
playPause.onRollOut = playPause.onReleaseOutside = function () {
if (this._currentframe == 10) this.gotoAndStop('pause');
else this.gotoAndStop('play');
}
playPause.onRelease = function() {
if (this._currentframe == 10) {
this.gotoAndStop('playOver');
this._parent.pauseIt();
} else {
this.gotoAndStop('pauseOver');
this._parent.unPauseIt();
}
};
//next button
nextbtn.onRollOver = function() {
this.gotoAndStop('nextOver');
}
nextbtn.onRollOut = next.onReleaseOutside=function () {
this.gotoAndStop('next');
};
nextbtn.onRealease = function() {
this._parent.playSong();
};

Rispondi quotando