A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [RESOLVED] Change song from XML using scripts in flash

  1. #1
    Member
    Join Date
    Sep 2009
    Posts
    57

    resolved [RESOLVED] Change song from XML using scripts in flash

    I have an mp3 on my site that is loaded via an xml. I have an action on the xml that allows any song to be played first by assigning an attribute. However, I want another song to play when a selected button is pressed on the flash file. But I do not want to load a new xml, instead, I want to change it using an attribute. Any who, here is the code that is used to create a sound and play selected song.


    //this function selects the music assigned with "musicnum" variable
    selectmusic = function() {
    //create a new sound variable
    sound = new Sound();

    //load the music
    sound.loadSound(songs[musicnum].attributes.src, true);
    //set volume
    sound.setVolume(volume);
    sound.play();
    playbtn.icon.gotoAndStop(2);
    playing = true;

    //select/deselect the menu items... if menu is pinned
    if (menuitems.length > 0) {
    pselected = selected;
    selected = undefined;
    pselected.onRollOut();
    menuitems[musicnum].onRollOver();
    selected = menuitems[musicnum];
    }

    //change the sound... if current sound is played completely
    sound.onSoundComplete = function(evt) {
    if (looping == true) {
    sound.start(0);
    } else {
    if (musicnum < songs.length-1) musicnum += 1; else musicnum = 0;
    selectmusic();
    }
    }
    }


    Now here is the xml

    Code:
    	<song text="''Waka Waka'' (This Time for Africa)[dm Exclusive Remix]" src="songs/africa.mp3" selected="true" />
    	<song text="daniel miguel dessins" src="songs/Colcci - Backstage.mp3" changes="true"/>
    and here is how the selected attribute is formed in the initial 'new XML' function.


    if (musicnode.childNodes[i].attributes.selected == "true") {
    musicnum = songs.length - 1;
    }


    PLEASE HELP

  2. #2
    Member
    Join Date
    Sep 2010
    Posts
    73
    I dont know if this willhelp you. but you can have this mp3player

    http://wiistream.net/downloads/My_Flas/as2mp3player.zip
    WiiStream A Social Movie Network Version 0.1.1 Demo Testers Aproved http://wiistream.net/WiiStream.exe

  3. #3
    Member
    Join Date
    Sep 2009
    Posts
    57
    Thank you!!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center