# XML sound linked to flash!

**URL:** <https://forum.kirupa.com/t/xml-sound-linked-to-flash/277287>\
**Category:** flash\
**Created:** [December 10, 2008, 10:27am UTC](https://forum.kirupa.com/t/xml-sound-linked-to-flash/277287 "2008-12-10T10:27:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christam1](https://avatars.discourse-cdn.com/v4/letter/c/839c29/32.png) [@Christam1](https://forum.kirupa.com/u/Christam1)\
**Post date:** [December 10, 2008, 10:27am UTC](https://forum.kirupa.com/t/xml-sound-linked-to-flash/277287/1 "2008-12-10T10:27:33Z")

</div>

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)

```auto
<?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

```auto
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 🙂
