title: Unwanted sound loop JavaScript
body: <pre><code>setInterval(collector, 1000/FPS);
  </code></pre>
  
  <p>This calls the collector, that runs the following:</p>
  
  <pre><code>function collector(){
      inputinterval();
      draw();
      soundplay();
      //DEBUG FEATURES BELOW
      //console.log(mousepos);
      //console.log(mousedrag);
  }
  </code></pre>
  
  <p>In <code>inputinterval</code> there is code that determines whether the user is dragging something or not. By default he is, but by pressing the spacebar it drops the element from the mouse pointer. Now this would be fun to have sound, so I did the following to test the sound:</p>
  
  <pre><code>//SOUND
  //function soundplay(){
  //  if (!(mousedrag)){
  //      snd_putdown.play();
  //  };
  //};
  </code></pre>
  
  <p>I've commented it out for now because it's looping even when no mouse button is pressed.</p>
  
  <p>The mousedrag is determined in an input function:</p>
  
  <pre><code>if (event.keyCode == 65) {
      mousedrag = true;
  }
  if (event.keyCode == 83) {
      mousedrag = false;
  }
  </code></pre>
  
  <p>Currently replaced by keyboard inputs since my mousebuttons aren't working either. This bit of code is part of <code>inputinterval()</code> that is called in the collector, that is called by the setInterval function. That causes tremendous looping. How would I go about doing the sound so that is not part of the loop, but does respond to the user dropping something (and picking it back up > dropping> etc...).</p>
  
  <p>Thanks in advance!</p>
  
  <p>EDIT: Well, I skipped the whole dropping of parts for now and choose to alter the design rather than breaking my head over such thing. I'd still like to know how to do this, but for now it can do without. The progress can be seen here, along with the source and what not: koewaffle.koding.com/pcgametest/index.html .</p>