Controlador de som ON/OFF e Loop no flash as3
Bom, eu fucei muito aqui no google, e consegui achar um tuto em inglês...
É muito interessante, o resultado foi mais do que eu esperava, em parte...
Eu quero só um controlador de som ON/OFF
não preciso nem de controle de volume...
Sò que, eis o problema, preciso muito que a musica tenha um LOOP, entendem?
que fique rodando continuamente o som...
Há algo que eu possa alterar para aproveitar o seguinte codigo ( que estou usando atualmente ) para fazer um loop?
( TUDO EM AS3 )
________________________
//imports the necessary as events
import flash.events.Event
import flash.events.MouseEvent;
var isPlaying:Boolean = new Boolean();
var pausePosition:Number = new Number();
//Create an instance of the Sound class
var soundClip:Sound = new Sound();
//Create a new SoundChannel Object
var sndChannel:SoundChannel = new SoundChannel();
//Load sound using URLRequest
soundClip.load(new URLRequest("trem.mp3"));
//Create an event listener that wll update once sound has finished loading
soundClip.addEventListener(Event.COMPLETE, onComplete, false, 0, true);
controller.addEventListener(MouseEvent.MOUSE_DOWN, btnPressController, false, 0, true);
stop_btn.addEventListener(MouseEvent.MOUSE_DOWN, btnPressStop, false, 0, true);
function onComplete(evt:Event):void {
//Play loaded sound
sndChannel = soundClip.play();
isPlaying = true;
}
function btnPressController(evt:MouseEvent):void{
switch(isPlaying)
{
case true:
controller.gotoAndStop(2);
pausePosition = sndChannel.position;
sndChannel.stop();
isPlaying = false;
break;
case false:
controller.gotoAndStop(1);
sndChannel = soundClip.play(pausePosition);
isPlaying = true;
break;
}
}
function btnPressStop(evt:MouseEvent):void{
pausePosition = 0;
sndChannel.stop();
controller.gotoAndStop(2);
isPlaying = false;
}
___________________________
( TUDO EM AS3 )
ou tenho que fazer outro mesmo?
Sabem de algum tuto ?
alguma dica??
Origado desde já!
( TUDO EM AS3 )
Discussão (5)
Carregando comentários...