44
Client-Side ActionScript Language Reference
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 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 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, which lets the user choose the microphone to be referenced by
Microphone.get()
, use
System.showSettings(2)
.
Example
The 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);
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.index
,
Microphone.muted
,
Microphone.names
,
Microphone.onStatus
,
MovieClip.attachAudio()
,
NetStream.attachAudio()
,
System.showSettings()