0
package {
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.*;
import flash.media.Microphone;
import flash.system.Security;
import flash.external.ExternalInterface;
import fl.controls.Slider;
import fl.events.SliderEvent;
import fl.controls.ProgressBar;
import flash.events.ProgressEvent;
import fl.controls.ProgressBarMode;
import fl.controls.ProgressBarDirection;
import flash.media.Sound;
public class mic extends MovieClip {
var micr:Microphone;
var aSlider:Slider;
var aPb:ProgressBar;
var timeout:Number=1000;
public function mic() {
micr = Microphone.getMicrophone();
micr.gain=60;
micr.rate=5;
micr.setSilenceLevel(7,timeout);
Security.showSettings("2");
micr.setUseEchoSuppression(true);
micr.setLoopBack(true);
aSlider = new Slider();
aSlider.width = 200;
aSlider.height = 3;
aSlider.snapInterval = 1;
aSlider.tickInterval = 1;
aSlider.maximum = 20;
aSlider.minimum = 3;
aSlider.value = micr.silenceLevel;
aSlider.move(25, 110);
addChild(aSlider);
aPb = new ProgressBar();
aPb.width = 200;
aPb.height = 3;
aPb.move(25,130);
aPb.direction = ProgressBarDirection.RIGHT;
aPb.mode = ProgressBarMode.MANUAL;
aPb.minimum = 0;
aPb.maximum = 100;
addChild(aPb);
if (micr != null) {
micr.setUseEchoSuppression(true);
micr.addEventListener(ActivityEvent.ACTIVITY, activityHandler);
micr.addEventListener(StatusEvent.STATUS, statusHandler);
aSlider.addEventListener(SliderEvent.CHANGE, changeHandler);
}
}
private function activityHandler(event:ActivityEvent):void {
if(event.activating){
ExternalInterface.call("noiseEvent()");
trace("activating=" + event.activating + ", activityLevel=" + this.micr.activityLevel);
}
aPb.setProgress(this.micr.activityLevel, aSlider.value);
}
private function statusHandler(event:StatusEvent):void {
trace("statusHandler: " + event);
}
private function changeHandler(event:SliderEvent):void {
micr.setSilenceLevel(event.target.value, timeout);
}
}
}
我需要監聽話筒活動,然後調用一些js功能。 這是我的整個代碼。 它的工作很好,但約5分鐘。然後沒有響應。有什麼建議麼?AS3話筒as3在一段時間後沒有響應
MacOSX的ML, 的Adobe Flash Player 11.5.31.5 的Shockwave Flash 11.5 R31
這很可能是由Chrome使用的Pepper Flash插件引起的。這是新的,有各種問題。您可以通過以下方式禁用它:chrome:// plugins - 然後展開細節並查找其路徑中具有「PepperFlash」的Flash插件。您可能會安裝普通的Flash插件。 –
我已經做到了。甚至重新安裝閃光燈。 –