Randoom MP3 Player?

[LEFT]Hi!

I have made MP3 player that reads external XML which contains of five songs. I want to play it randomly - every time you start player it starts with other song. Following songs doesn’t have to be in random.

I succeed to start playing randomly, but it got stucked and it doesn’t load other songs - can anyone, please, help me?

Here is my code:

var s:Sound = new Sound();
s.onSoundComplete = playSong;
s.setVolume(75);
 
// Array of songs
var sa:Array = new Array();

// Currently playing song
var cps:Number = -1;
 
// Position of music
var pos:Number;
 
// load the songs XML
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++)
 var j:Number = Math.round(Math.random()*(this.firstChild.childNodes.length -1)); //random part
 trace(this.firstChild.childNodes[j].firstChild.nodeValue); //random part
 sa.push(new Song(nodes[j].attributes.url, nodes[j].attributes.track)); 
 }
 playSong();
 }
xml.load("songs.xml");
 
// Play the MP3 File
function playSong():Void
{
 s = new Sound();
 s.onSoundComplete = playSong;
 mute.gotoAndStop("on");
 if(cps == sa.length - 1)
 {
  cps = 0;
  s.loadSound(sa[cps].earl, true);
 }
 else
 {
  s.loadSound(sa[++cps].earl, true);
 }
 trackInfo.text = sa[cps].track;
 playPause.gotoAndStop("pause");
 textPos = 0;
}
// Pauses the music
function pauseIt():Void
{
 pos = s.position;
 s.stop();
}
// Pauses the music
function unPauseIt():Void
{
 s.start(pos/1000);
}
// Music Controls
// Play/Pause Toggle
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
next.onRollOver = function()
{
 this.gotoAndStop("nextOver");
}
next.onRollOut = next.onReleaseOutside = function()
{
 this.gotoAndStop("next");
}
next.onRelease = function()
{
 this._parent.playSong();
}
// Previous Button
previous.onRollOver = function()
{
 this.gotoAndStop("previousOver");
}
previous.onRollOut = previous.onReleaseOutside = function()
{
 this.gotoAndStop("previous");
}
previous.onRelease = function()
{
 if (cps>0) 
 {
  cps= cps-2;
  this._parent.playSong();
 }
 else
 {
  cps == cps--;
  this._parent.playSong();
 }
}
// Mute Button
mute.onRollOver = function()
{
 if(this._currentframe == 1) this.gotoAndStop("onOver");
 else this.gotoAndStop("offOver");
}
mute.onRollOut = mute.onReleaseOutside = function()
{
 if(this._currentframe == 10) this.gotoAndStop("on");
 else this.gotoAndStop("off");
}
mute.onRelease = function()
{
 if(this._currentframe == 10)
 {
  this.gotoAndStop("offOver");
  s.setVolume(0);
 }
 else
 {
  this.gotoAndStop("onOver");
  s.setVolume(75);
 }
}

Thanks![/LEFT]