Random mp3 play

i have this code for an mp3 player and i would like to have it play the songs randomly…
Is there an easy way to make the code so it picks a random song everytime??

[COLOR=Blue]function getData (url:String, exitFunction:Function):Void {

var gXML:XML = new XML();
gXML.ignoreWhite = true;
gXML.onLoad = exitFunction;
gXML.load(url);

}
/////////////////////////////////////////////////////////////

function loadPlaylist (loaded:Boolean) {
if (loaded) {

    var mainStream_xml:XMLNode = this.childNodes[0];
    var stream_array:Array = [];
    
    for (var i:Number = 0; i < (mainStream_xml.childNodes.length); i ++) {
        stream_array* = new Array();
        stream_array*["file"] = mainStream_xml.childNodes*.attributes.file;
        stream_array*["name"] = mainStream_xml.childNodes*.attributes.name;
        
    }  // end for looping through childNodes
    _root.playlistArray = stream_array;
    
    gotoNextSong();
    
}

}

function gotoNextSong () {
if (_root.playlistArray.length > 0) {
if (_root.currentSong == 0) {
_root.bgSound_snd.loadSound(_root.playlistArray[_root.currentSong][“file”], true);
trace (_root.playlistArray[_root.currentSong][“name”]);
_root.songName_txt.text = _root.playlistArray[_root.currentSong][“name”];
_root.currentSong++;
} else {
trace (_root.playlistArray[_root.currentSong][“name”]);
_root.songName_txt.text = _root.playlistArray[_root.currentSong][“name”];
_root.bgSound_snd.loadSound(_root.playlistArray[_root.currentSong][“file”], true);
_root.currentSong++;
}
}
}

var playlistArray = new Array();
var currentSong = new Number(0);
// load and set the loop for the sound
var bgSound_snd:Sound = new Sound();

bgSound_snd.setVolume(50);

bgSound_snd.onSoundComplete = function() {
gotoNextSong();
}

getData(“playlist.xml”, loadPlaylist);
[/COLOR]
I should say I got the code from these forums, i am just getting into actionscript and tried to modify it myself but is not working
any help would be much appreciated…

Thanks kirupis!! :love: