2010-04-04 6 views
0

Frapper jouer plus d'une fois, provoque un écho et je ne peux pas arrêter mon lecteur mp3. Quelle est la meilleure pratique pour la lecture de mp3?lecture mp3 arrêt écho, as3

  var mySound:Sound = new Sound(); 
    playButton.addEventListener (MouseEvent.CLICK, myPlayButtonHandler); 
      var myChannel:SoundChannel = new SoundChannel(); 

      function myPlayButtonHandler (e:MouseEvent):void { 
        myChannel = mySound.play(); 
          } 
    stopButton.addEventListener(MouseEvent.CLICK, onClickStop); 
      function onClickStop(e:MouseEvent):void{ 
          myChannel.stop(); 
          } 

Répondre

1

Voici deux boutons pour contrôler le volume globalement. Faites-moi savoir si cela ne fonctionne pas.

var mySound:Sound = new Sound(); 
playButton.addEventListener (MouseEvent.CLICK, myPlayButtonHandler); 
var myChannel:SoundChannel = new SoundChannel(); 
     function myPlayButtonHandler (e:MouseEvent):void { 

      myChannel = mySound.play(); 
      } 
stopButton.addEventListener(MouseEvent.CLICK, onClickStop); 
     function onClickStop(e:MouseEvent):void{ 
      myChannel.stop(); 
      } 

/*-----------------------------------------------------------------*/ 
//global sound buttons, add instance of 'killswitch' and 'onswitch' to stage 
killswitch.addEventListener(MouseEvent.CLICK, clipKillSwitch); 
     function clipKillSwitch(e:MouseEvent):void{ 
var transform1:SoundTransform=new SoundTransform(); 
transform1.volume=0; 
flash.media.SoundMixer.soundTransform=transform1; 
      }  
onswitch.addEventListener(MouseEvent.CLICK, clipOnSwitch); 
     function clipOnSwitch(e:MouseEvent):void{ 
var transform1_:SoundTransform=new SoundTransform();   
transform1_.volume=1; 
flash.media.SoundMixer.soundTransform=transform1_;  
      } 
0

Je ferais plusieurs choses.

  1. Une fois que le jeu est atteint, enregistrez cet état dans un var. Ensuite, s'ils rejouent le jeu, ne faites rien si vous êtes déjà dans l'état 'play'.

Autre option: 2. Changez le bouton de lecture en bouton de pause. Ensuite, effectuez l'action d'arrêt si le bouton est touché, à la place. S'ils frappent alors en pause, alors retournez le bouton pour jouer.