Example
The following example sets the microphone rate to the user's preference (which you have
assigned to the
userRate
is not, the value is rounded to the nearest acceptable value that the sound capture device
supports.
active_mic.setRate(userRate);
The following example lets you use a ComboBox instance, called
at which your microphone captures sound. The current rate displays in a Label instance called
.
rate_lbl
this.createEmptyMovieClip("sound_mc", this.getNextHighestDepth());
var active_mic:Microphone = Microphone.get();
sound_mc.attachAudio(active_mic);
var rate_array:Array = new Array(5, 8, 11, 22, 44);
rate_cb.dataProvider = rate_array;
rate_cb.labelFunction = function(item:Object) {
return (item+" kHz");
};
for (var i = 0; i<rate_array.length; i++) {
if (rate_cb.getItemAt(i) == active_mic.rate) {
rate_cb.selectedIndex = i;
break;
}
}
function changeRate() {
active_mic.setRate(rate_cb.selectedItem);
rate_lbl.text = "Current rate: "+active_mic.rate+" kHz";
}
rate_cb.addEventListener("change", changeRate);
rate_lbl.text = "Current rate: "+active_mic.rate+" kHz";
The
MovieClip.getNextHighestDepth()
7 or later. If your SWF file includes a version 2 component, use the version 2 components
DepthManager class instead of the
See also
rate (Microphone.rate property)
setSilenceLevel (Microphone.setSilenceLevel
method)
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.
798
ActionScript classes
variable) if it is one of the following values: 5, 8, 11, 22, or 44. If it
method used in this example requires Flash Player
MovieClip.getNextHighestDepth()
, to change the rate
rate_cb
method.
Need help?
Do you have a question about the FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE and is the answer not in the manual?