有没有办法在Flash Player的本地存储设置面板上检测关闭事件?
package
{
import flash.display.Sprite;
import flash.system.Security;
import flash.system.SecurityPanel;
import flash.system.fscommand;
import flash.media.Video;
import flash.media.Camera;
import flash.media.Microphone;
import flash.net.NetStream;
import flash.net.NetConnection;
import flash.events.FocusEvent;
import flash.events.NetStatusEvent;
[SWF (width="320", height="240", backgroundColor="#ffffff", frameRate="10")]
public class Publisher extends Sprite
{
public var nc: NetConnection;
public var ns: NetStream;
public var video:Video;
public var camera: Camera;
public var microphone: Microphone;
public function stage_FocusEvent(e:FocusEvent):void {
stage.removeEventListener(FocusEvent.FOCUS_IN, stage_FocusEvent);
checkAccess();
}
public function checkAccess():void {
if (camera.muted) {
stage.focus = this;
stage.addEventListener(FocusEvent.FOCUS_IN, stage_FocusEvent);
Security.showSettings(SecurityPanel.PRIVACY);
}
else {
connect();
}
}
public function ns_onStatus(e:NetStatusEvent):void {
fscommand("NetStream::onStatus", e.info.code);
}
public function nc_onStatus(e:NetStatusEvent):void {
fscommand("NetConnection::onStatus", e.info.code);
if (e.info.code != "NetConnection.Connect.Success") return;
ns = new NetStream(nc);
ns.addEventListener(NetStatusEvent.NET_STATUS, ns_onStatus);
ns.attachCamera(camera);
microphone = Microphone.getMicrophone();
microphone.gain = 60;
ns.attachAudio(microphone);
ns.publish(streamId);
}
public function connect():void {
fscommand("connecting", "");
camera.setMode(320, 240, 10, false);
camera.setQuality(0, 80);
camera.setKeyFrameInterval(3);
video = new Video();
video.attachCamera(camera);
addChild(video);
nc = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, nc_onStatus);
nc.connect("rtmp://exmaple.com/appName");
}
public function Publisher() {
stage.showDefaultContextMenu = false;
camera = Camera.getCamera();
checkAccess();
}
}
}
答案 0 :(得分:1)
我发现这个肮脏的解决方法。当你关闭弹出窗口时,只要你移动鼠标触发别的东西,它就会告诉你。
// WHEN PRIVACY PANEL IS ON MOUSE EVENTS ARE DISABLE
stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
function onMouseMove(e:Event):void {
trace("privacy setting closed");
//REMOVE THE LISTENER ON FIRST TIME
stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
//dostuff
}
答案 1 :(得分:0)
我担心没有事件发生。 有关详细信息和可能的解决方法,请参阅this错误。