import flash.media.Microphone;
import flash.events.ActivityEvent;
import flash.events.Event;
import mx.controls.Alert;
import flash.events.StatusEvent;
public var mic:Microphone;
public function createMic():void
{
mic = Microphone.getMicrophone();
mic.setLoopBack(true);
mic.addEventListener(ActivityEvent.ACTIVITY, activity);
mic.addEventListener(StatusEvent.STATUS, status);
mic.addEventListener(Event.ACTIVATE, active);
}
private function active(event:Event):void
{
Alert.show('active');
}
private function status(event:StatusEvent):void
{
Alert.show("status");
}
private function activity(event:ActivityEvent):void
{
addEventListener(Event.ENTER_FRAME, showMicLevel);
}
private function showMicLevel(event:Event):void
{
Alert.show(mic.gain+" "+mic.activityLevel+" "+mic.silenceLevel+" "+mic.rate);
level.graphics.clear();
level.graphics.beginFill(0xccccff, 1);
level.graphics.drawRect(0, 0, (mic.activityLevel * 30), 100);
level.graphics.endFill();
}