You must be logged in to post Login Register
Search 

next/previous button with xml

User Post

4:03 am
September 1, 2009


mike

New Member

posts 1

1

Hi, thanks for the tutorials on XML, they are great. I am trying to make a simple flash application which loops throught the xml, I have this part done`-` However, Iwould like to have a next button,and when press it goes to the next entry in the xml. I am lost on this, and can't fins any examlples, can you please help?


my xml

my track 1

Band 1

1.mp3

my track 2

Band 2

2.mp3


My AS 3 Code

var xmlLoader:URLLoader = new URLLoader();

xmlLoader.addEventListener(Event.COMPLETE, showXML);

xmlLoader.load(new URLRequest(“playlist.xml”));

function showXML(e:Event):void {

XML.ignoreWhitespace = true; 

var songs:XML = new XML(e.target.data);

trace(songs.track.length());

var i:Number;

for (i=0; i < songs.track.length(); i++) {

trace(” Name of the song: “+ songs.track[i].title.text());

trace(” Name of the Band: “+ songs.track[i].band.text());

trace(” File Location of the song: “+ songs.track[i].file.text());

trace(“————————————————————”);

}

}


//everything is working now, add the buttons to go to the next song, or previous song

Basically when the app loads I want to load the first song(along with a field saying song 1 of X). then if the next button is pressed it goes to the next song in the xml?


Thanks,

Mike

Topic RSS 
Search