// Initialize variables
var trackToPlay:String;
var pausePosition:int = 0;
var songURL:URLRequest;
var i:uint;
// Initialize the XML, place the xml file name, initialize the URLRequest
// put URLRequest into a new URLLoader, and add event listener on
// myLoader listening for when the XML loading is complete
var myXML:XML = new XML();
var XML_URL:String = "mp3_playlist.xml";
var myXMLURL:URLRequest = new URLRequest(XML_URL);
var myLoader:URLLoader = new URLLoader(myXMLURL);
myLoader.addEventListener("complete", xmlLoaded);
// Create the xmlLoaded function. What happens when the XML file is fully read
function xmlLoaded(event:Event):void {
// Place the xml data into the myXML object
myXML = XML(myLoader.data);
// Access song 1 in the XML file to start the player
var firstSong:String = myXML..Song.songTitle[0];
var firstArtist:String = myXML..Song.songArtist[0];
songURL = new URLRequest("mp3_files/" + firstSong + ".mp3");
status_txt.text = "1. "+firstSong +" - "+firstArtist;
// Run the "for each" loop to iterate through all of the song items listed in the external XML file
for each (var Song:XML in myXML..Song) {
i++; // Increment the song counter by one
// Access the value of the "itemColor" node in our external XML file
var songTitle:String = Song.songTitle.toString();
// Access the value of the "itemLabel" node in our external XML file
var songArtist:String = Song.songArtist.toString();
// Adds each song into the list component through this loop
list.addItem( { label: i+". "+songTitle+" - "+songArtist, songString: songTitle, Artist: songArtist, songNum: i } );
}
var myArray = new Array (0,0);
list.selectedIndices = myArray; // This highlights song 1 by default
gotoAndStop(3);
}
//////////////////////////////////////////////
// CODE FOR FRAME 2
//////////////////////////////////////////////
// This is where and when the song switching takes place when a list cell is clicked
songURL = new URLRequest("mp3_files/" + trackToPlay + ".mp3");
//////////////////////////////////////////////
// CODE FOR FRAME 3
//////////////////////////////////////////////
stop();
var snd:Sound = new Sound();
var channel:SoundChannel;
var context:SoundLoaderContext = new SoundLoaderContext(5000, true);
snd.load(songURL, context);
channel = snd.play(pausePosition); // Start playing
// Playlist item click listener
list.addEventListener(Event.CHANGE, itemClick);
// Playlist item click function
function itemClick (event:Event):void {
channel.stop(); // stop play
status_txt.text = "Now Playing: " + event.target.selectedItem.label + ".mp3";
trackToPlay = event.target.selectedItem.songString;
gotoAndPlay(2);
}
AND ALL MY FILES ARE SAVED IN THE SAME FOLDER MY MP3'S IN 1 TITTLED mp3_files
AND MY MP3 XML FILE TITLED mp3_playlist
ALONG WITH MY FLASH FILE
WHAT AM I DOING WRONG TO GET THIS ERROR SOMEBODY PLEASE HELP ME