Hi there, I have some XML which is driving a voting system (poll) using PHP. The PHP is including the <name>, <image> and <flash> nodes which are then displayed in an output browser to the user.
Inside each flash object however, I want to include a separate MP3 file from the same XML file - from <song>. Could anyone point me in the right way for doing this? I’m not sure how to refer to the <song> nodes in Actionscript - I have the PHP all complete with the flash player I’ve made which appear for each candidate on the output PHP (contains a play and stop button).
XML CODE (poll.xml)
<?xml version="1.0"?>
<polls>
<poll title="Who do you think should win Pop Icons 2009?">
<answers>
<answer>
<name>Michael</name>
<tally>0</tally>
<image>http://www.clipartguide.com/_thumbs/0511-0706-2215-4025.jpg</image>
<flash>songs/1.swf</flash>
<song>songs/mp3s/1.mp3</song>
</answer>
<answer>
<name>Sophie</name>
<tally>0</tally>
<image>http://www.clipartguide.com/_thumbs/0060-0506-2417-2032.jpg</image>
<flash>songs/1.swf</flash>
<song>songs/mp3s/2.mp3</song>
</answer>
</answers>
</poll>
</polls>
ACTIONSCRIPT SO FAR
playlist = new XML();
playlist.ignoreWhite = true;
playlist.onLoad = function(success) {
if (success) {
_global.songfile = [];
for (var i = 0; i<playlist.childNodes[4].firstChild.length; i++) {
_global.songfile* = playlist.childNodes[4].firstChild.song;
trace(song*);
}
_root.createEmptyMovieClip("sound_mc", 1);
_root.sound_mc.sound_obj = new Sound();
_global.song_nr = random(songfile.length);
//_global.song_next = +1(songfile.length);
_root.sound_mc.songStarter(songfile[0]);
}
}
MovieClip.prototype.songStarter = function (song, name) {
this.sound_obj.loadSound(file,true)
this.onEnterFrame = function () {
if(this.sound_obj.position>0) {
delete this.onEnterFrame;
this._parent.display_txt.text="Now Playing";
} else {
this._parent.display_txt.text="loading..."
}
}
}
this.sound_obj.onSoundComplete = function () {
this._parent.sound_mc.sound_obj.stop();
}
_root.MUSIC.btn_play.onRelease = function () {
this._parent.sound_mc.songStarter(songfile[song_nr],songname[song_nr]);
}
_root.MUSIC.btn_stop.onRelease = function() {
this._parent.sound_mc.sound_obj.stop();
}
playlist.load("poll.xml");
I’m lost with the actionscript pulling on the XML but I think it’s almost refering to the right place…what do you guys think?
Thanks in advance