Microphone in Flash

To start using the microphone in Flash, the code is really quite simple, and can be retrieved from the F1 Help documentation within the Flash UI.

Here’s the main code that you will need to initialize the Microphone.

this.createEmptyMovieClip(“sound_mc”, this.getNextHighestDepth());
System.showSettings(2);
var active_mic:Microphone = Microphone.get();
sound_mc.attachAudio(active_mic);

One thing to note is that your Stage size must be at least 215 x 138 pixels for the System Settings to be displayed. This system Settings panel lets users allow or deny the Microphone. And there is a function to let Flash detect, what the user’s choice was. This allows you to have 2 different code, one for users with the Microphone, and one for users with no Microphones.

Continuing from the code above:

active_mic.onStatus = function(infoObj:Object) {
trace(active_mic.muted);
if (active_mic.muted) {
//put function here to activate NO MICROPHONE code
}else{
//put function here to activate MICROPHONE code
}
};

I left the trace inside to show you what is the difference of the number you get when you click allow or deny.

This is the basics of coding a Microphone in Flash. Hopefully, I’ll be having the chance to be playing more with the ActivityLevel part of the Microphone class in the coming weeks. Will share the code with you guys then.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>