External mp3 flash player problems

Hi all,

I’ve been working on an mp3 player that loads external mp3s from a directory, with id3 tags readouts etc etc. Everything works fine (after a while), but i have a weird problem.

I don’t want to limit the number of songs that can be played. Basically i just want the player to cycle through all the songs in the directory. All songs are named mp3-number.mp3 so i can cycle through them easily.
The problem however arises when i reach the last song. Flash tries to load an unexisting file and throws an error. I tried to code ways around this problem as follows:


 function newSong(songNumber){
	mySound.loadSound("music/mp3-" + songNumber + ".mp3", true);
	
	mySound.onLoad = function(success:Boolean) {
	if (success) {
 
		 playSong();
 
	}
	else {
		
		curTrackNum = 0; //curTrackNum is the var used to cycle through the songs
		newSong(0);
		
	}
}

This works in flash test mode (although it still gives the error), but it doesnt seem to work in firefox for some reason. It then decides to just stop at the last song and not cycle on to the first one again.

I realise the problem could be due to the error that flash throws, and actually i should have a valid way to count the number of files that are in the directory first. But i don’t know of a way… is this at all possible?

Thanks so much in advance! This site & forum have helped me through some tough flash times. This is my first post yay :wink: