ActionScript 2.0 Language Reference |
|
|
|
| ActionScript classes > Microphone > onActivity (Microphone.onActivity handler) | |||
onActivity = function(active:Boolean) {}
Invoked when the microphone starts or stops detecting sound. If you want to respond to this event handler, you must create a function to process its activity value.
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().
Availability: ActionScript 1.0; Flash Player 6
active:Boolean - A Boolean value set to true when the microphone starts detecting sound, and false when it stops.
The following example displays the amount of activity level in a ProgressBar instance called activityLevel_pb. When the microphone detects sound, it invokes the onActivity function, which modifies the ProgressBar instance.
var activityLevel_pb:mx.controls.ProgressBar;
activityLevel_pb.mode = "manual";
activityLevel_pb.label = "Activity Level: %3%%";
this.createEmptyMovieClip("sound_mc", this.getNextHighestDepth());
var active_mic:Microphone = Microphone.get();
sound_mc.attachAudio(active_mic);
active_mic.onActivity = function(active:Boolean) {
if (active) {
activityLevel_pb.indeterminate = false;
activityLevel_pb.label = "Activity Level: %3%%";
} else {
activityLevel_pb.indeterminate = true;
activityLevel_pb.label = "Activity Level: (inactive)";
}
};
this.onEnterFrame = function() {
activityLevel_pb.setProgress(active_mic.activityLevel, 100);
};
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 version 2 components' DepthManager class instead of the MovieClip.getNextHighestDepth() method.
setSilenceLevel (Microphone.setSilenceLevel method)
|
|
|
|