Ver Mensaje Individual
  #3 (permalink)  
Antiguo 18/09/2011, 17:58
fletcher2009
 
Fecha de Ingreso: noviembre-2010
Mensajes: 94
Antigüedad: 13 años, 5 meses
Puntos: 11
Respuesta: musica aleatoria en flash

Prueba este código

Código AS3:
Ver original
  1. import flash.media.Sound;  
  2. import flash.net.URLRequest;  
  3. import flash.media.SoundChannel;  
  4. import flash.events.Event;  
  5.  
  6. playsong();  
  7. //var songs:Array=new Array("music1.mp3","music2.mp3","music3.mp3","music4.mp3");  
  8. var sound:Sound;  
  9. var soundChannel:SoundChannel;  
  10. var randnum:uint;  
  11. function playsong()  
  12. {  
  13. randnum=Math.floor(Math.random()*6);  
  14. sound=new Sound();  
  15. var songs:String= "music" + randnum + ".mp3";  
  16. sound.load(new URLRequest("musics/"+songs));  
  17. soundChannel=sound.play();  
  18. soundChannel.addEventListener(Event.SOUND_COMPLETE,playrandomsong);  
  19. }  
  20. function playrandomsong(e:Event)  
  21. {  
  22. playsong();  
  23. }