title: Actionscript 3: Monitoring the activity level for multiple Microphones doesn't seem to work
body: <p>For a project I want to show all available webcams and microphones, so that the user can easily select whichever webcam/microphone combination they prefer. I run into an issue with the microphones listing though.</p>
  
  <p>Each microphone is listed with an activity animation and it's name. I am able to list all Microphones just fine (using the Microphone.names Array), but it seems like I can only get the activity viewer to work for one microphone. The other microphones show up with '-1' activity, which (as far as I know) is Flex for 'present, but not in use'. When unplugging the microphone that <em>does</em> show activity, the next one (in my case, the mic-in line on my motherboard) shows up with '0' activity (it's not connected, so that makes sense).</p>
  
  <p>During my testing I have a total of 3 microphones available, the not-connected onboard mic-in port, and two connected microphones.</p>
  
  <p>For testing purposes I use a timer that traces the current microphone activity each 100ms and the graph is also shown.</p>
  
  <p>It does not seem to matter what default microphone I set via flash' settings panel.</p>
  
  <p><strong>The code</strong></p>
  
  <p>I've only attached the revelant code snippets below to make it easier for you to read through them. Please let me know if you prefer the entire code.</p>
  
  <p><strong>Main application.mxml</strong></p>
  
  <p><em>Note: cont is a VBox. i is defined before this code snippet.</em></p>
  
  <pre><code>var mics:Array = Microphone.names;
  for(i=0; i &lt; mics.length; i++){
     var mic:settingsMicEntry = new assets.settingsMicEntry;
     mic.d = {name: mics[i], index: i};
  
     cont.addChild(mic);
  }
  </code></pre>
  
  <p><strong>assets/settingsMicEntry.mxml</strong></p>
  
  <p><em>timer is defined before this code snippet. the SoundTransform is added to silence local microphone playback. Excluding this code does not solve the problem, sadly (I've tried). display is an MXML Canvas object.</em></p>
  
  <pre><code>mic = Microphone.getMicrophone(d.index);
  if(mic){
      // Temporary: The Microphones' visualizer
     var bar:Box = new Box();
     bar.y = 50;
     bar.height = 0;
     bar.width = 66;
     bar.setStyle("backgroundColor", 0x003300);
     display.addChild(bar);
  
     var tf:SoundTransform = new SoundTransform(0);
     mic.setLoopBack(true);
     mic.soundTransform = tf;
  
     timer = new Timer(100);
     timer.addEventListener(TimerEvent.TIMER, function(e:TimerEvent):void{
        var h:int = Math.floor((display.height/100)*mic.activityLevel);
  
        bar.height = (h&gt;-1) ? h : 0;
        bar.y = (h&gt;-1) ? display.height-h : display.height;
  
        trace('TIMER: '+h+' from '+d.name);
     });
     timer.start();
  }
  </code></pre>
  
  <p>I'm pulling my hear out here, so any help is much appreciated!</p>
  
  <p>Thanks,</p>
  
  <p>-Dave</p>
  
  <p><em>Ps.: Pardon the messiness of the code!</em></p>