RSS

flash.media.Microphone

14 Jun
import flash.media.Microphone;
import flash.events.ActivityEvent;
import flash.events.Event;
//import mx.controls.Alert;
import flash.events.StatusEvent;

var mic:Microphone;
createMic();

function createMic():void
{
	mic = Microphone.getMicrophone();
	mic.setLoopBack(true);
	mic.addEventListener(ActivityEvent.ACTIVITY, activity);
	mic.addEventListener(StatusEvent.STATUS, status);
	mic.addEventListener(Event.ACTIVATE, active);
}

function active(event:Event):void
{
	trace('active');
}

function status(event:StatusEvent):void
{
	trace("status");
}

function activity(event:ActivityEvent):void
{
	addEventListener(Event.ENTER_FRAME, showMicLevel);
}

function showMicLevel(event:Event):void
{
	//trace(mic.gain+" "+mic.activityLevel+" "+mic.silenceLevel+" "+mic.rate);
	//trace(mic.gain+" "+mic.activityLevel+" "+mic.silenceLevel+" "+mic.rate);
	if(mic.activityLevel>50){
		trace(mic.gain+" "+mic.activityLevel+" "+mic.silenceLevel+" "+mic.rate);
	}
	this.graphics.clear();
	this.graphics.beginFill(0xccccff, 1);
	this.graphics.drawRect(0, 0, (mic.activityLevel * 30), 100);
	this.graphics.endFill();
}
Read More
Advertisements
 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: