Wednesday, March 18, 2009

MP3 Play Multiple Songs Using An Array

/* FRAME SCRIPT */


var songs=new Array();
songs = ["beach", "shogun","africa"];
// --------------------------------------

// get a song
var n:Number = 0;// item in the list
whatsong = songs[n];
extension = "mp3";
songFilename = whatsong + "." + extension;
// -------------------------------------------

// load the song from inside a folder
ThisSong = new Sound();
songFolder ="songs/world/";
ThisSong.loadSound(songFolder + songFilename,true);

var whereAmI:Number = 0;
ThisSong.start(whereAmI,1);
songName = "Now playing: " + whatsong;


/* NEXT SONG BUTTON */
on (release) {

if (n == songs.length-1) {

n = 0;
} else {
n++;
}


whatsong = songs[n];
songName = "Now playing: "+whatsong;

extension = "mp3";
songFilename = whatsong+"."+extension;

ThisSong = new Sound();
songFolder = "songs/world/";
ThisSong.loadSound(songFolder+songFilename,true);

var whereAmI:Number = 0;
ThisSong.start(whereAmI,1);

}

No comments: