Microphone classThe Microphone class lets you capture audio from a microphone attached to the computer that is running Flash Player. When used with Flash Media Server, you can transmit, play, and on Flash Media Interactive Server and Flash Media Development Server, optionally record the audio being captured. With these capabilities, you can develop a wide range of media applications. You can implement real-time collaboration applications using audio/video, such as Adobe® ConnectNow on Acrobat.com. Other examples are instant messaging with audio, applications to record presentations so that others can replay them later, and so on. Flash Player provides similar video capabilities; for more information, see the Camera class entry. You can also use a Microphone object without a server—for example, to transmit sound from your microphone through the speakers on your local system. To create or reference a Microphone object, use the Microphone.get() method. Note: Flash Player displays a Privacy dialog box in
which the user can choose whether to allow or deny access to the
microphone. Make sure that your Stage size is at least 215 by 138
pixels; this is the minimum size that Flash Player requires to display the
dialog box.
Method summary
Property summary
Microphone.activityLevelpublic activityLevel : Number [read-only] 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. ExampleThe 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);
};
Note: The MovieClip.getNextHighestDepth() method
used in this example requires Flash Player 7 or later. If your SWF
file includes a version 2 component, use the DepthManager class
from the component framework instead of the MovieClip.getNextHighestDepth() method.
Microphone.codecpublic codec : String [read-only] The codec used to compress audio. Possible values are "NELLYMOSER" (the default value) and "SPEEX". To set this value, use the setCodec() method. AvailabilityFlash Media Server 3.5 (not required); Flash Player 10. See alsoMicrophone.encodeQualitypublic encodeQuality: Number [read-only] The encoded speech quality when using the Speex codec. Possible values are from 0 to 10. The default value is 6. Higher numbers represent higher quality but require more bandwidth, as shown in the following table. The bit rate values that are listed represent net bit rates and do not include packetization overhead.
AvailabilityFlash Media Server 3.5 (not required); Flash Player 10. See alsoMicrophone.framesPerPacketpublic framesPerPacket : Number [read-only] The number of Speex speech frames transmitted in a packet (message). Each frame is 20 ms long. The default value is two frames per packet. AvailabilityFlash Media Server 3.5 (not required); Flash Player 10. See alsoMicrophone.gainpublic gain : Number [read-only] The amount by which the microphone boosts the signal before transmitting it. Valid values are 0 to 100. The default value is 50. ExampleThe following example uses a ProgressBar instance called gain_pb to display and a NumericStepper instance called gain_nstep to set the microphone’s gain value: this.createEmptyMovieClip("sound_mc", this.getNextHighestDepth());
var active_mic:Microphone = Microphone.get();
sound_mc.attachAudio(active_mic);
gain_pb.label = "Gain: %3";
gain_pb.mode = "manual";
gain_pb.setProgress(active_mic.gain, 100);
gain_nstep.value = active_mic.gain;
function changeGain() {
active_mic.setGain(gain_nstep.value);
gain_pb.setProgress(active_mic.gain, 100);
}
gain_nstep.addEventListener("change", changeGain);
Note: The MovieClip.getNextHighestDepth() method
used in this example requires Flash Player 7 or later. If your SWF
file includes a version 2 component, use the DepthManager class
from the component framework instead of the MovieClip.getNextHighestDepth() method.
Microphone.get()public static get([index:Number]) : Microphone Note: The correct syntax is Microphone.get().
To assign the Microphone object to a variable, use syntax like var active_mic:Microphone = Microphone.get().
Returns a reference to a Microphone object for capturing audio. To begin capturing the audio, you must attach the Microphone object either to a MovieClip object (see MovieClip.attachAudio()) or to a NetStream object (see NetStream.attachAudio()). (The NetStream object is available only with Flash Media Server.) Unlike objects that you create by using the new constructor, multiple calls to Microphone.get() reference the same microphone. Thus, if your script contains the lines mic1 = Microphone.get() and mic2 = Microphone.get(), both mic1 and mic2 reference the same (default) microphone. In general, you shouldn’t pass a value for index; simply use the Microphone.get() method to return a reference to the default microphone. By means of the Microphone Settings panel, the user can specify the default microphone that Flash Player should use. If you pass a value for index, you might be trying to reference a microphone other than the one the user prefers. You might use index in rare cases—for example, if your application is capturing audio from two microphones at the same time. When a SWF file tries to access the microphone returned by the Microphone.get() method—for example, when you issue NetStream.attachAudio() or MovieClip.attachAudio()—Flash Player displays a Privacy dialog box in which the user can choose whether to allow or deny access to the microphone. (Make sure that your Stage size is at least 215 by 138 pixels; this is the minimum size that Flash Player requires to display the dialog box.) When the user responds to this dialog box, the Microphone.onStatus() event handler returns an information object that indicates the user’s response. To determine whether the user has denied or allowed access to the camera without processing this event handler, use Microphone.muted. The user can also specify permanent privacy settings for a particular domain by right-clicking (Windows) or Control-clicking (Macintosh) while a SWF file is playing and selecting Settings. When the Privacy dialog box opens, the user selects Remember. You can’t use ActionScript to set the Allow or Deny value for a user, but you can display the Privacy dialog box for the user by using System.showSettings(0). If the user selects Remember, Flash Player no longer displays the Privacy dialog box for SWF files from this domain. If Microphone.get() returns null, either the microphone is in use by another application or there are no microphones installed on the system. To determine whether any microphones are installed, use Microphones.names.length. To display the Flash Player Microphone Settings panel, in which the user can choose the microphone to be referenced by Microphone.get(), use System.showSettings(2). Parameters
ReturnsIf index is not specified, this method returns a reference to the default microphone, or if it is not available, to the first available microphone. If no microphones are available or installed, the method returns null. If index is specified, this method returns a reference to the requested microphone, or null if it is not available. ExampleThe following example lets the user specify the default microphone and then captures audio and plays it back locally. To avoid feedback, you may want to test this code while wearing headphones. this.createEmptyMovieClip("sound_mc", this.getNextHighestDepth());
System.showSettings(2);
var active_mic:Microphone = Microphone.get();
sound_mc.attachAudio(active_mic);
Note: The MovieClip.getNextHighestDepth() method
used in this example requires Flash Player 7 or later. If your SWF
file includes a version 2 component, use the DepthManager class
from the component framework instead of the MovieClip.getNextHighestDepth() method.
Microphone.indexpublic index : Number [read-only] A zero-based integer that specifies the index of the microphone, as reflected in the array returned by Microphone.names. ExampleThe following example displays the names of the sound capturing devices available on your computer system in a ComboBox instance called mic_cb. An instance of the Label component, called mic_lbl, displays the index microphone. You can use the ComboBox to switch between the devices. var mic_lbl:mx.controls.Label;
var mic_cb:mx.controls.ComboBox;
this.createEmptyMovieClip("sound_mc", this.getNextHighestDepth());
var active_mic:Microphone = Microphone.get();
sound_mc.attachAudio(active_mic);
mic_lbl.text = "["+active_mic.index+"] "+active_mic.name;
mic_cb.dataProvider = Microphone.names;
mic_cb.selectedIndex = active_mic.index;
var cbListener:Object = new Object();
cbListener.change = function(evt:Object) {
active_mic = Microphone.get(evt.target.selectedIndex);
sound_mc.attachAudio(active_mic);
mic_lbl.text = "["+active_mic.index+"] "+active_mic.name;
};
mic_cb.addEventListener("change", cbListener);
Note: The MovieClip.getNextHighestDepth() method
used in this example requires Flash Player 7 or later. If your SWF
file includes a version 2 component, use the DepthManager class
from the component framework instead of the MovieClip.getNextHighestDepth() method.
Microphone.mutedpublic muted : Boolean [read-only] A Boolean value that specifies whether the user has denied access to the microphone (true) or allowed access (false). When this value changes, Microphone.onStatus() is invoked. For more information, see Microphone.get(). Microphone.namepublic name : String [read-only] The name of the current sound capture device, as returned by the sound capture hardware. ExampleThe following example displays information about the sound capture device or devices on your computer system, including an array of names and the default device: var status_ta:mx.controls.TextArea;
status_ta.html = false;
status_ta.setStyle("fontSize", 9);
var microphone_array:Array = Microphone.names;
var active_mic:Microphone = Microphone.get();
status_ta.text = "The default device is: "+active_mic.name+newline+newline;
status_ta.text += "You have "+microphone_array.length+" device(s) installed."+newline+newline;
for (var i = 0; i<microphone_array.length; i++) {
status_ta.text += "["+i+"] "+microphone_array[i]+newline;
}
Microphone.namespublic static names : Array {read-only]
Note: The correct syntax is Microphone.names.
To assign the return value to a variable, use syntax like var micNames_array:Array = Microphone.names.
To determine the name of the current microphone, use active_mic.name,
where active_mic is the variable to which you assigned the
results of Microphone.get().
An array of strings reflecting the names of all available sound capture devices. This API gets the names of all available sound capture devices without displaying the Flash Player Privacy dialog box to the user. This array behaves the same as any other ActionScript array, implicitly providing the zero-based index of each sound capture device and the number of sound capture devices on the system (by means of Microphone.names.length). Accessing Microphone.names requires an extensive examination of the hardware, and it may take several seconds to build the array. In most cases, you can just use the default microphone. ExampleThe following code returns information on the array of audio devices: var allMicNames_array:Array = Microphone.names;
trace("Microphone.names located these device(s):");
for(i=0; i < allMicNames_array.length; i++){
trace("[" + i + "]: " + allMicNames_array[i]);
}
For example, the following information could be displayed: Microphone.names located these device(s): [0]: Crystal SoundFusion(tm) [1]: USB Audio Device See alsoArray class entry in the ActionScript 2.0 Language Reference, Microphone.get(), Microphone.name Microphone.onActivity()public onActivity = function(active:Boolean) {}
Invoked when the microphone starts or stops detecting sound. To specify the amount of sound required to invoke Microphone.onActivity(true), and the amount of time that must elapse without sound before Microphone.onActivity(false) is invoked, use Microphone.setSilenceLevel(). Parameters
ExampleThe following example displays true or false in the Output panel when the microphone starts or stops detecting sound: var active_mic:Microphone = Microphone.get();
_root.attachAudio(active_mic);
active_mic.onActivity = function(mode){
trace("The microphone detects sound: " + mode);
// Mode outputs either true or false.
}
Microphone.onStatus()public onStatus = function(infoObject:Object) {}
Invoked when the user allows or denies access to the microphone. If you want to respond to this event handler, you must create a function to process the information object generated by the microphone. When a SWF file tries to access the microphone, Flash Player displays a Privacy dialog box in which the user can choose whether to allow or deny access.
To determine whether the user has denied or allowed access to the microphone without processing this event handler, use Microphone.muted. Note: If the user chooses to permanently allow or
deny access for all SWF files from a specified domain, this method
is not invoked for SWF files from that domain unless the user later
changes the privacy setting. For more information, see Microphone.get().
Parameters
ExampleThe following example displays the Privacy dialog box, where the user can allow or deny access to the microphone. If the user chooses to deny access, “muted” is displayed in large red text. If microphone access is allowed, the user does not see this text. this.createTextField("muted_txt", this.getNextHighestDepth(), 10, 10, 100, 22);
muted_txt.autoSize = true;
muted_txt.html = true;
muted_txt.selectable = false;
muted_txt.htmlText = "<a href=\"asfunction:System.showSettings\"><u>Click Here</u></a> to Allow/Deny access.";
this.createEmptyMovieClip("sound_mc", this.getNextHighestDepth());
var active_mic:Microphone = Microphone.get();
sound_mc.attachAudio(active_mic);
active_mic.onStatus = function(infoObj:Object) {
status_txt._visible = active_mic.muted;
muted_txt.htmlText = "Status: <a href=\"asfunction:System.showSettings\"><u>"+infoObj.code+"</u></a>";
};
this.createTextField("status_txt", this.getNextHighestDepth(), 0, 0, 100, 22);
status_txt.html = true;
status_txt.autoSize = true;
status_txt.htmlText = "<font size='72' color='#FF0000'>muted</font>";
status_txt._x = (Stage.width-status_txt._width)/2;
status_txt._y = (Stage.height-status_txt._height)/2;
status_txt._visible = active_mic.muted;
Note: The MovieClip.getNextHighestDepth() method
used in this example requires Flash Player 7 or later. If your SWF
file includes a version 2 component, use the DepthManager class
from the component framework instead of the MovieClip.getNextHighestDepth() method.
Microphone.ratepublic rate : Number [read-only] The rate at which the microphone is capturing sound, in kHz. The default value is 8 kHz if your sound capture device supports this value. Otherwise, the default value is the next available capture level above 8 kHz that your sound capture device supports, usually 11 kHz. To set this value, use Microphone.setRate(). Microphone.setCodec()public setCodec(codec:String) : Void Sets the codec used to compress audio. Available codecs are Nellymoser (the default value) and Speex. If you use the Nellymoser codec, you can set the sample rate using Microphone.setRate(). If you use the Speex codec, the sample rate is set to 16 kHz. Speex includes voice activity detection (VAD) and automatically reduces bandwidth when no voice is detected. When using the Speex codec, Adobe recommends that you set the silence level to 0. To set the silence level, use the Microphone.setSilenceLevel() method. AvailabilityFlash Media Server 3.5 (not required); Flash Player 10. Parameters
Microphone.setEncodeQuality()public setEncodeQuality(quality:Number) : Void Sets the encoded speech quality when using the Speex codec. AvailabilityFlash Media Server 3.5 (not required); Flash Player 10. Parameters
See alsoMicrophone.setFramesPerPacket()public setFramesPerPacket(frames:Number) : Void Sets the number of Speex speech frames transmitted in a packet (message). Each frame is 20 ms long. The default value is two frames per packet. The more Speex frames in a message, the lower the bandwidth required but the longer the delay in sending the message. Fewer Speex frames increases bandwidth required but reduces delay. AvailabilityFlash Media Server 3.5 (not required); Flash Player 10. Parameters
See alsoMicrophone.setGain()public setGain(gain:Number) : Void Sets the microphone gain—that is, the amount by which the microphone should multiply the signal before transmitting it. A value of 0 tells Flash Player to multiply by 0; that is, the microphone transmits no sound. You can think of this setting like a volume knob on a stereo: 0 is no volume and 50 is normal volume. Numbers below 50 specify lower than normal volume, and numbers above 50 specify higher than normal volume. Parameters
Microphone.setRate()public setRate(kHz:Number) : Void Sets the rate, in kHz, at which the microphone should capture sound when using the Nellymoser codec. When using the Speex codec, the sampling rate is set to 16 kHz. Parameters
ExampleThe following example sets the microphone rate to the user’s preference (which you have assigned to the userRate variable) if it is one of the following values: 5, 8, 11, 22, or 44. If it is not, the value is rounded to the nearest acceptable value that the sound capture device supports. active_mic.setRate(userRate); Microphone.setSilenceLevel()public setSilenceLevel(silenceLevel:Number, [timeOut:Number]) : Void Sets the minimum input level that should be considered sound and (optionally) the amount of silent time signifying that silence has actually begun.
Activity detection is the ability to detect when audio levels suggest that a person is talking. When someone is not talking, bandwidth can be saved because there is no need to send the associated audio stream. This information can also be used for visual feedback so that users know that they (or others) are silent. Silence values correspond directly to activity values. Complete silence is an activity value of 0. Constant loud noise (as loud as can be registered based on the current gain setting) is an activity value of 100. After gain is appropriately adjusted, your activity value is less than your silence value when you’re not talking; when you are talking, the activity value exceeds your silence value. This method is similar in purpose to Camera.setMotionLevel(); both methods are used to specify when the onActivity event handler should be invoked. However, these methods have a significantly different impact on publishing streams.
Parameters
ExampleThe following example changes the silence level based on the user’s input in a NumericStepper instance called silenceLevel_nstep. The ProgressBar instance called silenceLevel_pb modifies its appearance depending on whether the audio stream is considered silent. If the audio stream is not silent, the progress bar displays the activity level of the audio stream. var silenceLevel_pb:mx.controls.ProgressBar;
var silenceLevel_nstep:mx.controls.NumericStepper;
this.createEmptyMovieClip("sound_mc", this.getNextHighestDepth());
var active_mic:Microphone = Microphone.get();
sound_mc.attachAudio(active_mic);
silenceLevel_pb.label = "Activity level: %3";
silenceLevel_pb.mode = "manual";
silenceLevel_nstep.minimum = 0;
silenceLevel_nstep.maximum = 100;
silenceLevel_nstep.value = active_mic.silenceLevel;
var nstepListener:Object = new Object();
nstepListener.change = function(evt:Object) {
active_mic.setSilenceLevel(evt.target.value, active_mic.silenceTimeOut);
};
silenceLevel_nstep.addEventListener("change", nstepListener);
this.onEnterFrame = function() {
silenceLevel_pb.setProgress(active_mic.activityLevel, 100);
};
active_mic.onActivity = function(active:Boolean) {
if (active) {
silenceLevel_pb.indeterminate = false;
silenceLevel_pb.setStyle("themeColor", "haloGreen");
silenceLevel_pb.label = "Activity level: %3";
} else {
silenceLevel_pb.indeterminate = true;
silenceLevel_pb.setStyle("themeColor", "0xFF0000");
silenceLevel_pb.label = "Activity level: (inactive)";
}
};
Note: The MovieClip.getNextHighestDepth() method
used in this example requires Flash Player 7 or later. If your SWF
file includes a version 2 component, use the DepthManager class
from the component framework instead of the MovieClip.getNextHighestDepth() method.
See also the example for Camera.setMotionLevel(). Microphone.setUseEchoSuppression()public setUseEchoSuppression(suppress:Boolean) : Void Specifies whether to use the echo suppression feature of the audio codec. The default value is false unless the user has selected Reduce Echo in the Flash Player Microphone Settings panel. Echo suppression is an effort to reduce the effects of audio feedback, which is caused when sound going out the speaker is picked up by the microphone on the same computer. (This is different from echo cancellation, which completely removes the feedback.) Generally, echo suppression is advisable when the sound being captured is played through speakers—instead of a headset—on the same computer. If your SWF file allows users to specify the sound output device, you may want to call Microphone.setUseEchoSuppression(true) if they indicate that they are using speakers and will be using the microphone as well. Users can also adjust these settings in the Flash Player Microphone Settings panel. Parameters
ExampleThe following example turns on echo suppression if the user selects a CheckBox instance called useEchoSuppression_ch. The ProgressBar instance called activityLevel_pb displays the current activity level of the audio stream. var useEchoSuppression_ch:mx.controls.CheckBox;
var activityLevel_pb:mx.controls.ProgressBar;
this.createEmptyMovieClip("sound_mc", this.getNextHighestDepth());
var active_mic:Microphone = Microphone.get();
sound_mc.attachAudio(active_mic);
activityLevel_pb.mode = "manual";
activityLevel_pb.label = "Activity Level: %3";
useEchoSuppression_ch.selected = active_mic.useEchoSuppression;
this.onEnterFrame = function() {
activityLevel_pb.setProgress(active_mic.activityLevel, 100);
};
var chListener:Object = new Object();
chListener.click = function(evt:Object) {
active_mic.setUseEchoSuppression(evt.target.selected);
};
useEchoSuppression_ch.addEventListener("click", chListener);
Microphone.silenceLevelpublic silenceLevel : Number [read-only] An integer that specifies the amount of sound required to activate the microphone and invoke Microphone.onActivity(true). The default value is 10. ExampleThe following example changes the silence level based on the user’s input in a NumericStepper instance called silenceLevel_nstep. The ProgressBar instance called silenceLevel_pb modifies its appearance depending on whether the audio stream is considered silent. If the audio stream is not silent, the progress bar displays the activity level of the audio stream. var silenceLevel_pb:mx.controls.ProgressBar;
var silenceLevel_nstep:mx.controls.NumericStepper;
this.createEmptyMovieClip("sound_mc", this.getNextHighestDepth());
var active_mic:Microphone = Microphone.get();
sound_mc.attachAudio(active_mic);
silenceLevel_pb.label = "Activity level: %3";
silenceLevel_pb.mode = "manual";
silenceLevel_nstep.minimum = 0;
silenceLevel_nstep.maximum = 100;
silenceLevel_nstep.value = active_mic.silenceLevel;
var nstepListener:Object = new Object();
nstepListener.change = function(evt:Object) {
active_mic.setSilenceLevel(evt.target.value, active_mic.silenceTimeOut);
};
silenceLevel_nstep.addEventListener("change", nstepListener);
this.onEnterFrame = function() {
silenceLevel_pb.setProgress(active_mic.activityLevel, 100);
};
active_mic.onActivity = function(active:Boolean) {
if (active) {
silenceLevel_pb.indeterminate = false;
silenceLevel_pb.setStyle("themeColor", "haloGreen");
silenceLevel_pb.label = "Activity level: %3";
} else {
silenceLevel_pb.indeterminate = true;
silenceLevel_pb.setStyle("themeColor", "0xFF0000");
silenceLevel_pb.label = "Activity level: (inactive)";
}
};
Note: The MovieClip.getNextHighestDepth() method
used in this example requires Flash Player 7 or later. If your SWF
file includes a version 2 component, use the DepthManager class
from the component framework instead of the MovieClip.getNextHighestDepth() method.
Microphone.silenceTimeoutpublic silenceTimeout : Number [read-only] A numeric value representing the number of milliseconds between the time the microphone stops detecting sound and the time Microphone.onActivity(false) is invoked. The default value is 2000 (2 seconds). To set this value, use Microphone.setSilenceLevel(). ExampleThe following example enables the user to control the amount of time between when the microphone stops detecting sound and when Microphone.onActivity(false) is invoked. The user controls this value by using a NumericStepper instance called silenceTimeOut_nstep. The ProgressBar instance called silenceLevel_pb modifies its appearance depending on whether the audio stream is considered silent. If the audio stream is not silent, the progress bar displays the activity level of the audio stream. var silenceLevel_pb:mx.controls.ProgressBar;
var silenceTimeOut_nstep:mx.controls.NumericStepper;
this.createEmptyMovieClip("sound_mc", this.getNextHighestDepth());
var active_mic:Microphone = Microphone.get();
sound_mc.attachAudio(active_mic);
silenceLevel_pb.label = "Activity level: %3";
silenceLevel_pb.mode = "manual";
silenceTimeOut_nstep.minimum = 0;
silenceTimeOut_nstep.maximum = 10;
silenceTimeOut_nstep.value = active_mic.silenceTimeOut/1000;
var nstepListener:Object = new Object();
nstepListener.change = function(evt:Object) {
active_mic.setSilenceLevel(active_mic.silenceLevel, evt.target.value 1000);
};
silenceTimeOut_nstep.addEventListener("change", nstepListener);
this.onEnterFrame = function() {
silenceLevel_pb.setProgress(active_mic.activityLevel, 100);
};
active_mic.onActivity = function(active:Boolean) {
if (active) {
silenceLevel_pb.indeterminate = false;
silenceLevel_pb.setStyle("themeColor", "haloGreen");
silenceLevel_pb.label = "Activity level: %3";
} else {
silenceLevel_pb.indeterminate = true;
silenceLevel_pb.setStyle("themeColor", "0xFF0000");
silenceLevel_pb.label = "Activity level: (inactive)";
}
};
Note: The MovieClip.getNextHighestDepth() method
used in this example requires Flash Player 7 or later. If your SWF
file includes a version 2 component, use the DepthManager class
from the component framework instead of the MovieClip.getNextHighestDepth() method.
Microphone.useEchoSuppressionpublic useEchoSuppression : Boolean [read-only] A Boolean value that specifies whether echo suppression is being used. This property is true if echo suppression is enabled, and otherwise false. The default value is false unless the user has selected Reduce Echo in the Flash Player Microphone Settings panel. ExampleThe following example turns on echo suppression if the user selects a CheckBox instance called useEchoSuppression_ch. The ProgressBar instance called activityLevel_pb displays the current activity level of the audio stream. var useEchoSuppression_ch:mx.controls.CheckBox;
var activityLevel_pb:mx.controls.ProgressBar;
this.createEmptyMovieClip("sound_mc", this.getNextHighestDepth());
var active_mic:Microphone = Microphone.get();
sound_mc.attachAudio(active_mic);
activityLevel_pb.mode = "manual";
activityLevel_pb.label = "Activity Level: %3";
useEchoSuppression_ch.selected = active_mic.useEchoSuppression;
this.onEnterFrame = function() {
activityLevel_pb.setProgress(active_mic.activityLevel, 100);
};
var chListener:Object = new Object();
chListener.click = function(evt:Object) {
active_mic.setUseEchoSuppression(evt.target.selected);
};
useEchoSuppression_ch.addEventListener("click", chListener);
Note: The MovieClip.getNextHighestDepth() method
used in this example requires Flash Player 7 or later. If your SWF
file includes a version 2 component, use the DepthManager class
from the component framework instead of the MovieClip.getNextHighestDepth() method.
|
|