Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SecurityPanel close event

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;
    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();
        }
    }
}
like image 239
vinnitu Avatar asked Feb 02 '26 07:02

vinnitu


1 Answers

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
}
like image 53
Mathieu Gosselin Avatar answered Feb 04 '26 01:02

Mathieu Gosselin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!