1 person found this helpful
you working on flex / air? if it is flex, and your songs are on server, then I would use Javaa/ any other server scripting language to get me the list of names of the files in folder and I would use some Math.random to get a random song from the list.
the mp3 files are on my hard drive, were not using a server and it's a flash application not an air does that help? Thank you for your response!
Below is the code i have come up with through hours of googling etc but sometimes it wont play a sound any thoughts on this? All of my urls are correct, the method works, its just sometimes i ll click the play button and no sound will play and then i click it again and the sound will play. Should i use ceil instead of floor? Thank you in advance!
private var randSound:Sound;
private var channel:SoundChannel;
private var my_sounds:Array = ["sounds/hisbuttocks.mp3", "sounds/hisfoot.mp3", "sounds/hiship.mp3", "sounds/hisknee", "sounds/hisleg", "sounds/hisshin"];
//random sound function:
private function playRand():void
var randVal:int = Math.floor(Math.random()*my_sounds.length);
var urlname:String = my_sounds[randVal];
var request:URLRequest = new URLRequest(urlname);
randSound = new Sound(request);
channel = randSound.play();
"sounds/hisknee", "sounds/hisleg", "sounds/hisshin"
Just add ".mp3" to these. Yes?
Thanks, I figured it was something minor i guess it really is true that tired eyes don't see bugs! Thank you!!!