is there a way to detect the close event on the Local Storage Settings Panel of the Flash Player?
package
{
import flash.display.Sprite;
import flash.system.Security;
import flash.system.SecurityPanel;
import flash.system.fscommand;
import flash.media.Video;
开发者_StackOverflowimport 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();
}
}
}
I find this dirty workaround. Not perfect it will just tell you when you close the popup and as soon as you move the mouse trigger something else.
// 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
}
I'm afraid there is no event for that. See this bug for more info and possible workarounds.
精彩评论