I have been trying to adapt an mp3 player so that it always plays randomly from its xml playlist. I dont want this function to be able to be turned on and off, i just want constant random play, so there will be no need for any new buttons.

The mp3 player has some scripting in the fla and has two external .as files, one controlling the xml load and one controlling the player. I am unsure where to put the script in for random play or how to script it. I would be incredibly appreciative if anyone could help me in this matter.

The scripting in frame 1 of the timeline of the Fla goes as follows:

var xmlClass = new Xmlload();
var playClass = new Player();

this.pause_btn.onRelease = function() {
playClass.pauseIt();
};
this.play_btn.onRelease = function() {
playClass.unPauseIt();

};

There is then two external .as files:

Player.as

class Player {

//Properties

var s:Sound;

var cps:Number;

var pos:Number;

//Constructor

function Player() {

s = new Sound();

s.setVolume(75);

cps = -1;

}

//Methods

function playSong():Void {

s = new Sound();

if (cps == _root.xmlClass.sa.length-1) {

cps = 0;

s.loadSound(_root.xmlClass.sa[cps], true);

_root.display_txt.text = _root.xmlClass.names[cps];

} else {

s.loadSound(_root.xmlClass.sa[++cps], true);

_root.display_txt.text = _root.xmlClass.names[cps];

}

}

function pauseIt():Void {

pos = s.position;

s.stop();

}

function unPauseIt():Void {

s.start(pos/1000);

}

}


and

xmlload.as

import mx.utils.Delegate;

class Xmlload {

//Properties

var nodes:Array;

var sa:Array;

var names:Array;

var xml:XML;

//Constructor

function Xmlload() {

nodes = new Array();

sa = new Array();

names = new Array();

xml = new XML();

xml.ignoreWhite = true;

delLoad();

}

//Methods

public function delLoad():Void {

xml.onLoad = Delegate.create(this, loadXml);

xml.load("playlist.xml");

}

public function loadXml():Void {

nodes = xml.firstChild.childNodes;

for (var i = 0; i<nodes.length; i++) {

sa.push(nodes[i].attributes.url);

names.push(nodes[i].attributes.name);

}

_root.playClass.playSong();

}

}