User Guide

Microphone class 41
Description
Property (read-only); a numeric value that specifies the amount of sound the microphone is
detecting. Values range from 0 (no sound is being detected) to 100 (very loud sound is being
detected). The value of this property can help you determine a good value to pass to the
Microphone.setSilenceLevel() method.
If the microphone is available but is not yet being used because neither
MovieClip.attachAudio() nor NetStream.attachAudio() has been called, this property
is set to -1.
Example
The following example displays the activity level of the current microphone in a ProgressBar
instance called
activityLevel_pb:
var activityLevel_pb:mx.controls.ProgressBar;
activityLevel_pb.mode = "manual";
activityLevel_pb.label = "Activity Level: %3%%";
activityLevel_pb.setStyle("themeColor", "0xFF0000");
this.createEmptyMovieClip("sound_mc", this.getNextHighestDepth());
var active_mic:Microphone = Microphone.get();
sound_mc.attachAudio(active_mic);
this.onEnterFrame = function() {
activityLevel_pb.setProgress(active_mic.activityLevel, 100);
};
active_mic.onActivity = function(active:Boolean) {
if (active) {
var haloTheme_str:String = "haloGreen";
} else {
var haloTheme_str:String = "0xFF0000";
}
activityLevel_pb.setStyle("themeColor", haloTheme_str);
};
The MovieClip.getNextHighestDepth() method used in this example requires Flash Player
7 or later. If your SWF file includes a v2 component (version 2 of the Macromedia
Component Architecture), use the DepthManager class from the component framework
instead of the
MovieClip.getNextHighestDepth() method.
See also
Microphone.setGain()