I was wondering how I could build an array like this:
var songs:Array = new Array(
[playList: listName[song: songName, src: songSrc],[song: songName, src: songSrc],[song: songName, src: songSrc]],
[playList: listName[song: songName, src: songSrc],[song: songName, src: songSrc],[song: songName, src: songSrc]],
[playList: listName[song: songName, src: songSrc],[song: songName, src: songSrc],[song: songName, src: songSrc]]
);
I have xml that looks like:
<music>
<playlist title="Joey's Jams">
<song title="Chico Man - Say What" src="music/pl1/song1.mp3" />
<song title="Amy Winehouse - Valerie" src="music/pl1/song2.mp3" />
<song title="The Flaming Lips - The W.A.N.D" src="music/pl1/song3.mp3" />
</playlist>
<playlist title="Jon's P-List">
<song title="Nas - Ether" src="music/pl2/song1.mp3" />
<song title="Tupac - Hail Mary" src="music/pl2/song2.mp3" />
<song title="Tupac - Changes" src="music/pl2/song3.mp3" />
</playlist>
<playlist title="Marvin's Mix">
<song title="Beck - Girl" src="music/pl3/song1.mp3" />
<song title="Bruce Springsteen - Spirit In the Night" src="music/pl3/song2.mp3" />
<song title="Sugar Ray - Fly" src="music/pl3/song3.mp3" />
</playlist>
</music>
I have it all looping with this right now:
songxml.onLoad = function() {
var listLength = songxml.firstChild.childNodes.length;
for (var i = 0; i < listLength; i++) {
var listTitle = songxml.firstChild.childNodes*.attributes.title;
var songLength = songxml.firstChild.childNodes*.childNodes.length;
playlist.push(listTitle);
for (var k = 0; k < songLength; k++) {
var songTitle = songxml.firstChild.childNodes*.childNodes[k].attributes.title;
var songSrc = songxml.firstChild.childNodes*.childNodes[k].attributes.src;
songs.push({songTitle:songTitle, songSrc:songSrc});
}
}
init();
};
songxml.load("songlist.xml");
its just right now i have two arrays but the songs array isnt separated by anything…any ideas??