hiya im making a music player with flash and its just getting songs at random from a php script which is outputing all the song files in xml format it works except it plays the same song twice sometimes im not sure how to write a check to say if last song played = current song then pick a new song
any help would be appreciated cheers
i have a link going to my test page which is http://www.aaron-m.co.nz/new/ and the .fla file link is http://www.aaron-m.co.nz/new/index.fla
i have the actionscript in 2 frames,
heres the script from the first
mymusic = new XML();
mymusic.ignoreWhite = true;
mymusic.load("index2.php");
mymusic.onLoad = function(success) {
songnumber = this.firstChild.childNodes.length - 1;
var mymusics = mymusic.firstChild.childNodes;
var count1 = music_frame = Math.ceil(Math.random()*songnumber);
numb3r.text = count1
trace(count1)
var songs = mymusics[count1].firstChild.nodeValue;
names.text = songs;
}
here is the second frame
stop();
trace(names.text);
stopAllSounds();
var mysound:Sound = new Sound();
var song1 = names.text
mysound.loadSound(song1, true);
mySound.start(0);
test.text = song1;
mysound.onSoundComplete = function(){_root.gotoAndPlay(1)};
i have a basic button which is just for testing purposes its
on(release){
gotoAndPlay(1);
}
and the php script which is outputting the music files in the directory
<?
header('content-type: text/xml');
echo "<?xml version=\"1.0\"?>";
$dir = ".";
$files = scandir($dir);
printf( "<music>");
foreach($files as $key => $value){
if(ereg('mp3$',$value)){
printf( "<song>".$value."</song>
");
}
}
printf( "</music>");
?>