PDA

View Full Version : Flash + XML Question *help*



elimit
04-19-2006, 04:07 PM
Ok, so im trying to make a functional mediaplayer using Flash and XML .... its going good, i found a tutorial and its functiuoning but there somthing i need help with
the way i have it now, the media player has 10 songs, it starts on a random song and doesent continue onto the other song. ( ex. www.derekmarshall.ca )
the way i want it, is it starts on a certain song, and continues with the next songs. i cant figure it out.... heres my Actionscript and XML

NOTE : i ripped the actionscript right from the tutorial, so there might be somtihng in there i need to chage... any idea would be awesome!


Actionscript :

stop();
playlist = new XML();
playlist.ignoreWhite = true;
playlist.onLoad = function(success) {
if (success) {
_global.songname = [];
_global.songband = [];
_global.songfile = [];
for (var i = 0; i<playlist.firstChild.childNodes.length; i++) {
_global.songname[i] = playlist.firstChild.childNodes[i].attributes.name;
_global.songfile[i] = playlist.firstChild.childNodes[i].attributes.file;
trace(songname[i]+" "+songfile[i]);
}
}
_root.createEmptyMovieClip("sound_mc", 1);
_root.sound_mc.sound_obj = new Sound();
_global.song_nr = random(songfile.length);
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr]);
};
MovieClip.prototype.songStarter = function(file, name) {
this.sound_obj.loadSound(file, true);
this.onEnterFrame = function() {
if (this.sound_obj.position>0) {
delete this.onEnterFrame;
this._parent.display_txt.text = name;
} else {
this._parent.display_txt.text = "loading...";
}
};
this.sound_obj.onSoundComplete = function() {
(song_nr == songfiles.length-1) ? _global.song_nr=0 : _global.song_nr++;
_root.sound_mc.songStarter(songfiles[song_nr], songname[song_nr]);
};
};
btn_play.onRelease = function() {
this._parent.sound_mc.songStarter(songfile[song_nr], songname[song_nr]);
};
btn_stop.onRelease = function() {
this._parent.sound_mc.sound_obj.stop();
};
btn_fw.onRelease = function() {
(song_nr == songfile.length-1) ? _global.song_nr=0 : _global.song_nr++;
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr]);
};
btn_rev.onRelease = function() {
(song_nr == 0) ? _global.song_nr=songfile.length-1 : _global.song_nr--;
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr]);
};
playlist.load("playlist.xml");


-------------------------------------------------

Playlist.xml

<?xml version="1.0" encoding="UTF-8"?>
<songs>
<song name ="Luck Be A Lady" file="t1.mp3" />
<song name ="King Of The Road" file="t2.mp3" />
<song name ="My Romance" file="t3.mp3" />
<song name ="Autumn Leaves" file="t4.mp3" />
<song name ="Saturday Night ..." file="t5.mp3" />
<song name ="Aint That A kick In The Head" file="t6.mp3" />
<song name ="Dancing Cheek to Cheek" file="t7.mp3" />
<song name ="Beyond The Sea" file="t8.mp3" />
<song name ="Desafinado " file="t9.mp3" />
<song name ="The Best Is Yet To Come" file="t10.mp3" />
</songs>