Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

lezão

loop na musica

Recommended Posts

Ola galera, boa noite!

Gostaria de saber como acrescentar um loop neste codigo q estou usando ....

 

ele é AS3..!

 

 

CODIGO

 


var s:Sound = new Sound(new URLRequest(
"sugar.mp3"));

var fl_SC:SoundChannel;

fl_SC = s.play();

var tocando:Boolean = true;

btn.addEventListener(MouseEvent.CLICK, tocaSom);

function tocaSom(me:MouseEvent):void {
if (!tocando){
	fl_SC = s.play();
	tocando = true;
	btn.gotoAndStop(3);

}else{
	fl_SC.stop();
	tocando = false;
	btn.gotoAndStop(2);
}
}

Compartilhar este post


Link para o post
Compartilhar em outros sites

Ola Marcos, boa noite!

 

Cara eu tentei fazer assim e naun deu certo

 

var s:Sound = new Sound(new URLRequest(
"sugar.mp3"));

var fl_SC:SoundChannel;

fl_SC = s.play();

var tocando:Boolean = true;

btn.addEventListener(MouseEvent.CLICK, tocaSom);

function tocaSom(me:MouseEvent):void {
       if (!tocando){
               fl_SC = s.play();
               tocando = true;
               btn.gotoAndStop(3);

       }else{
               fl_SC.stop();
               tocando = false;
               btn.gotoAndStop(2);
       }
private function loop(event:Event = null):void {

       channel = sound.play();
       channel.addEventListener(Event.SOUND_COMPLETE, loop);
}
}

Compartilhar este post


Link para o post
Compartilhar em outros sites

Executa faixa ao clicar em Play, o loop é automático:

 

var audio:Sound = new Sound();
var arquivoSom:URLRequest = new URLRequest("loop.mp3"); //faixa com 9 segundos
audio.load(arquivoSom);

var canalSom:SoundChannel = new SoundChannel();
var tocando:Boolean = false;

player_mc.stop_btn.addEventListener(MouseEvent.CLICK, paraSom);
player_mc.play_btn.addEventListener(MouseEvent.CLICK, tocaSom);


function tocaSom(e:MouseEvent):void 
{
if(tocando != true){
	canalSom = audio.play(0, int.MAX_VALUE); // mágica p/loop >> entre os parênteses		
	tocando = true;
}
}
function paraSom(e:MouseEvent):void 
{
canalSom.stop();
tocando = false;
}

 

 

Abraços ;)

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.