gpt4 book ai didi

flash - SecurityPanel关闭事件

转载 作者:行者123 更新时间:2023-12-02 04:10:47 24 4
gpt4 key购买 nike

有没有办法在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();
}
}
}

最佳答案

我发现这个肮脏的解决方法。这并不完美,它只会告诉您何时关闭弹出窗口,并且一旦您移动鼠标就会触发其他事件。

// 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
}

关于flash - SecurityPanel关闭事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5315076/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com