Eu acho besteira fazer um preloder para carregar a música, porque pelo tutorial, ele está usando streaming, então, ele vai carregando a música e tocando, e mesmo que o usuário tenha uma conexão fraca ele sempre vai escutando a música, se você for usar um carregador vai demorar muito para carregar, ele vai fica sem som.
Procurando no Help do Flash, encontrei esse código:
| ActionScript |
this.createTextField("message_txt", this.getNextHighestDepth(), 10, 10, 300, 22); this.createTextField("status_txt", this.getNextHighestDepth(), 10, 50, 300, 40); status_txt.autoSize = true; status_txt.multiline = true; status_txt.border = false; var my_sound:Sound = new Sound(); my_sound.onLoad = function(success:Boolean) { if (success) { this.start(); message_txt.text = "Finished loading"; } }; my_sound.onSoundComplete = function() { message_txt.text = "Clearing interval"; clearInterval(my_interval); }; my_sound.loadSound("Beatles - Can't Buy Me Love.mp3", false); var my_interval:Number; my_interval = setInterval(checkProgress, 100, my_sound); function checkProgress(the_sound:Sound):Void { var pct:Number = Math.round(the_sound.getBytesLoaded()/the_sound.getBytesTotal()*100); status_txt.text = the_sound.getBytesLoaded()+" of "+the_sound.getBytesTotal()+" bytes ("+pct+"%)"; } |
Com isso, ele vai carregar sua música, e quando acabar ele começa a tocar. Faz um teste em sua máquina, e você vai ver que demora e muito para carregar a Música. Mas é você que sabe.
Qualquer coisa é só falar.
Falow