This content has been marked as final.
Show 4 replies
-
1. Random MP3 Button
abeall Apr 2, 2007 7:04 PM (in response to Mike_Watt)You could use PHP or another server-side language to scan the directory for all .mp3 files and returns XML, or you could create a static .xml file listing out all the MP3 files(which you update as needed), and either way you load the XML and load a random file. Something like this:
XML:
<audio>
<track file="mysong1.mp3" />
<track file="mysong2.mp3" />
<track file="mysong3.mp3" />
<track file="mysong4.mp3" />
<track file="mysong5.mp3" />
<track file="mysong6.mp3" />
</audio>
ActionScript:
var myAudio = new Sound();
var myXML = new XML();
myXML.ignoreWhite = true;
myXML.load('songlist.xml'); // or point it to a PHP file which returns XML
myXML.onLoad = function(){
var randomSong = myXML.firstChild.childNodes[random(myXML.firstChild.childNodes.length)];
myAudio.loadSound(randomSong.attributes.file);
}
This is not tested, but that's the general idea.
Good luck. -
2. Re: Random MP3 Button
Mike_Watt Apr 2, 2007 11:32 PM (in response to abeall)This seems straight forward enough... but still, would you (or anyone) be willing to set this up for a fee? I will create the FLA with the GUI as needed and you (or someone) write the script (including php, etc.) that is needed to execute it? Then, all I'd need to know is how to update the file (if a static xml file)...
Thoughts? I imagine this wouldn't be too much work for someone who knows what they're doing...
I would also be willing to negotiate for ad placement, etc... I can't disclose the site right now, but it is going to be part of a small network supporting a national - and very well known - radio program with a target demo of Males 18-54. Anyway, details for anyone who is actually interested... (abeall - you have first dibs is you want them.... )
I can be emailed at Skippy [at] nyc (dot) rr <dot> com.
Thanks! -
3. Re: Random MP3 Button
abeall Apr 4, 2007 7:51 AM (in response to Mike_Watt)Well, the script I posted up top is basically done, give it a shot. Just copy paste it into frame 1, change the 'file' paths in the XML to real files you have on your server, and make sure myXML.load is pointing to the file. -
4. Re: Random MP3 Button
abeall Apr 4, 2007 7:53 AM (in response to Mike_Watt)Oh, you want it to work when you click a button. Try modifying the ActionScript on frame 1 to this:
var myAudio = new Sound();
var myXML = new XML();
myXML.ignoreWhite = true;
myXML.load('songlist.xml'); // or point it to a PHP file which returns XML
function loadRandomSong(){
var randomSong = myXML.firstChild.childNodes[random(myXML.firstChild.childNodes.length)];
myAudio.loadSound(randomSong.attributes.file);
}
Then on the button put in the actions:
on(release){
loadRandomSong();
}

