MP3 Player XML help

Hi all i have a little problems…

I followed the MP3 player tutorial on this website (great site, video tutorials)

http://www.gotoandlearn.com

Everything runs smoothly, but I noticed that the tutorial maker did not include a “Previous song” button to go back to the previous song. He has a play/pause button and a next button. I’m wondering if someone can help me create a “previous song” button. Here is the code


[SIZE=2]//Sets up the sound[/SIZE]
[SIZE=2]var s:Sound = new Sound();[/SIZE]
[SIZE=2]s.onSoundComplete = playSong;[/SIZE]
 
 
[SIZE=2]//sets volume to 75%[/SIZE]
[SIZE=2]var vol:Number = 80;[/SIZE]
[SIZE=2]s.setVolume(vol);[/SIZE]
 
 
[SIZE=2]//Array of songs[/SIZE]
[SIZE=2]var sa:Array = new Array();[/SIZE]
 
[SIZE=2]//Currently Playing[/SIZE]
[SIZE=2]var cps:Number = -1;[/SIZE]
 
[SIZE=2]//Position of Music[/SIZE]
[SIZE=2]var pos:Number;[/SIZE]
 
 
[SIZE=2]//Load songs XML[/SIZE]
[SIZE=2]var xml:XML = new XML();[/SIZE]
[SIZE=2]xml.ignoreWhite = true;[/SIZE]
[SIZE=2]xml.onLoad = function() [/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]var nodes:Array = this.firstChild.childNodes;[/SIZE]
[SIZE=2]for (var i=0; i<nodes.length; i++) [/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]sa.push(nodes*.attributes.url);[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]playSong();[/SIZE]
[SIZE=2]}[/SIZE]
 
 
[SIZE=2]xml.load("songs.xml");[/SIZE]
 
 
[SIZE=2]//Play MP3[/SIZE]
[SIZE=2]function playSong():Void [/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]s = new Sound();[/SIZE]
[SIZE=2]if (cps == sa.length-1) [/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]cps = 0;[/SIZE]
[SIZE=2]s.loadSound(sa[cps], true);[/SIZE]
[SIZE=2]} else [/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]s.loadSound(sa[++cps], true);[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]playPause.gotoAndStop("pause");[/SIZE]
[SIZE=2]}[/SIZE]
 
[SIZE=2]//Pauses the music[/SIZE]
[SIZE=2]function pauseIt():Void[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]pos = s.position;[/SIZE]
[SIZE=2]s.stop();[/SIZE]
 
[SIZE=2]}[/SIZE]
[SIZE=2]//Unpauses the music[/SIZE]
[SIZE=2]function unPauseIt():Void[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]s.start(pos/1000) [/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]//Go to previous song[/SIZE]
[SIZE=2]function prevSong():Void[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]if (cps == sa.length++)[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]cps = 0;[/SIZE]
[SIZE=2]s.loadSound(sa[cps], true);[/SIZE]
[SIZE=2]} else[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]s.loadSound(sa[--cps], true);[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]}[/SIZE]
 
[SIZE=2]//Music Controls[/SIZE]
 
[SIZE=2]//Play/Pause Toggle[/SIZE]
[SIZE=2]playPause.onRollOver = function()[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]if(this._currentframe == 1) [/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]this.gotoAndStop("pauseOver");[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]else [/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]this.gotoAndStop("playOver");[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]playPause.onRollOut = playPause.onReleaseOutside = function()[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]if(this._currentframe == 11) [/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]this.gotoAndStop("pause");[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]else [/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]this.gotoAndStop("play");[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]playPause.onRelease = function()[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]if(this._currentframe == 11)[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]this.gotoAndStop("playOver");[/SIZE]
[SIZE=2]this._parent.pauseIt();[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]else[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]this.gotoAndStop("pauseOver");[/SIZE]
[SIZE=2]this._parent.unPauseIt();[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]//Next Button[/SIZE]
[SIZE=2]next.onRollOver = function()[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]this.gotoAndStop("nextOver");[/SIZE]
[SIZE=2]}[/SIZE]
 
[SIZE=2]next.onRollOut = next.onReleaseOutside = function()[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]this.gotoAndStop("next");[/SIZE]
[SIZE=2]}[/SIZE]
 
[SIZE=2]next.onRelease = function()[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]this._parent.playSong();[/SIZE]
[SIZE=2]}[/SIZE]
 
 
[SIZE=2]//Prev Button[/SIZE]
[SIZE=2]prev.onRollOver = function()[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]this.gotoAndStop("prevOver");[/SIZE]
[SIZE=2]}[/SIZE]
 
[SIZE=2]prev.onRollOut = prev.onReleaseOutside = function()[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]this.gotoAndStop("prev");[/SIZE]
[SIZE=2]}[/SIZE]
 
[SIZE=2]prev.onRelease = function()[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]this._parent.prevSong();[/SIZE]
[SIZE=2]} [/SIZE]
[SIZE=2]//Volume[/SIZE]
[SIZE=2]//Turn it down!![/SIZE]
[SIZE=2]volDown.onRollOver = function()[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]this.gotoAndStop("volOver");[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]volDown.onRollOut = volDown.onReleaseOutside = function()[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]this.gotoAndStop("vol");[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]volDown.onPress = function()[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]s.setVolume(vol -=10);[/SIZE]
[SIZE=2]if (vol == -10) {vol = 0}[/SIZE]
[SIZE=2]trace(vol)[/SIZE]
[SIZE=2]}[/SIZE]
 
 
[SIZE=2]//Turn it Up!![/SIZE]
[SIZE=2]volUp.onRollOver = function()[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]this.gotoAndStop("volOver");[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]volUp.onRollOut = volDown.onReleaseOutside = function()[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]this.gotoAndStop("vol");[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]volUp.onPress = function()[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]s.setVolume(vol +=10);[/SIZE]
[SIZE=2]if (vol == 160) {vol = 150}[/SIZE]
[SIZE=2]trace(vol)[/SIZE]
[SIZE=2]}[/SIZE]

When i test movie, the very first song in the XML plays. I click the “Previous song” button to jump to the very last song i the XML but it doesnt work… it comes up with error message#


Error opening URL "file:///G|/Multi%2DMedia%20System/undefined"

But when i click the “Next song” button and listen to a song halfway in the XML, THEN click the “Previous song” button, it does go back until i get to the first song.

I was hoping someone could help me find a way of playing from the very last song in the XML after i clicked the “Previous song” button from the first song in the XML.