Looping audio with AS3

  • elBurroDiablo
  • Novice
  • Novice
  • User avatar
  • Posts: 16

Post 3+ Months Ago

The code below is doing exactly what I want it to do...BUT I need the sound clip to loop. Any suggestions??

Please help! Thank you!!!



Code: [ Select ]
var soundReq:URLRequest = new URLRequest("Assets/Audio/drums01.mp3");
var sound:Sound = new Sound();
var soundControl:SoundChannel = new SoundChannel();
sound.load(soundReq);
 
sound.addEventListener(Event.COMPLETE, onComplete);
 
 
function onComplete(event:Event):void{
    drums1_mc.addEventListener(MouseEvent.CLICK, playSound);
    drumsStop_mc.addEventListener(MouseEvent.CLICK, stopSound);
}
 
function playSound(event:MouseEvent):void{
    soundControl = sound.play();
}
 
function stopSound(event:MouseEvent):void{
    soundControl.stop();
}
 
  1. var soundReq:URLRequest = new URLRequest("Assets/Audio/drums01.mp3");
  2. var sound:Sound = new Sound();
  3. var soundControl:SoundChannel = new SoundChannel();
  4. sound.load(soundReq);
  5.  
  6. sound.addEventListener(Event.COMPLETE, onComplete);
  7.  
  8.  
  9. function onComplete(event:Event):void{
  10.     drums1_mc.addEventListener(MouseEvent.CLICK, playSound);
  11.     drumsStop_mc.addEventListener(MouseEvent.CLICK, stopSound);
  12. }
  13.  
  14. function playSound(event:MouseEvent):void{
  15.     soundControl = sound.play();
  16. }
  17.  
  18. function stopSound(event:MouseEvent):void{
  19.     soundControl.stop();
  20. }
  21.  
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

Post Information

  • Total Posts in this topic: 1 post
  • Users browsing this forum: No registered users and 7 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.