views:

46

answers:

1

I have an mp3 player based on the School of Flash code. When I click "next song" I need it to go to the next song, unless it's the last song in the playlist in which case it needs to go back to song number 1 in the playlist.

The following code doesn't seem to do the trick, any ideas where I am going wrong?

var songlist:XMLList;
var currentIndex:Number = 0;

and..

function nextSong(e:Event):void
{
 if (currentIndex < (songlist.length() - 1))
 {
  currentIndex++;
 }
 else
 {
  currentIndex = 0;
 }

 var nextReq:URLRequest = new URLRequest(songlist[1].url);
 var nextTitle:Sound = new Sound(nextReq);
 sc.stop();
 title_txt.text = songlist[1].title;
 artist_txt.text = songlist[1].artist;
 sc = nextTitle.play();
 songPlaying = true;
 currentSound = nextTitle;
}
+2  A: 

Shouldn't it be songlist[currentIndex] instead of songlist[1]?

Claus Wahlers
Doh! Knew I needed a fresh pair of eyes. Many thanks.
Tom Hoad