M > Microphone.get |
![]() ![]() ![]() |
Microphone.get
Microphone, audio, sound, Microphone.get, get, constructor
Communications/Microphone/Methods/get
Availability
Flash Player 6.
Usage
Microphone.get([index
])
Note: The correct syntax is Microphone.get()
. To assign the Microphone object to a variable, use syntax like activeMicrophone
= Microphone.get()
.
Parameters
index
An optional zero-based integer that specifies which microphone to get, as determined from the array returned by the Microphone.names
property.
To get the default microphone (which is recommended for most applications), omit this parameter.
Returns
![]() |
If |
![]() |
If |
Description
Method; returns a reference to a Microphone object for capturing audio. To actually begin capturing the audio, you must attach the Microphone object to a MovieClip object (see Mouse (object)
).
Unlike objects that you create 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 (discussed later in this section), the user can specify the default microphone Flash 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 casesfor example, if your application is capturing audio from two microphones at the same time.
When a movie tries to access the microphone returned by the Microphone.get
methodfor example, when you issue Mouse (object)
the Flash Player displays a Privacy dialog box that lets the user choose whether to allow or deny access to the microphone. (Make sure your Stage size is at least 215 x 138 pixels; this is the minimum size Flash 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 movie is playing, choosing Settings, opening the Privacy panel, and selecting Remember.
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
.
Example
The following example lets the user specify the default microphone, then captures audio and plays it back locally. To avoid feedback, you may want to test this code while wearing headphones.
System.showSettings(2); myMic = Microphone.get(); _root.attachAudio(myMic);
See also
Microphone.index
, Microphone.muted
, Microphone.names
, Microphone.onStatus
, Mouse (object)
![]() ![]() ![]() |