Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flash security settings panel - Listening for close event?

When using Flash with a microphone or camera, the user is prompted to allow access to those devices. This is done through the built in security settings panel.

Is there a way to be notified by an event handler when the user clicks on the close button of the security settings panel? This does not seem to be possible...

For the microphone, it is possible to receive a status event when the user changes the settings in the security panel, but this event is triggered while the user still has the panel open.

like image 835
J. Volkya Avatar asked Aug 04 '11 16:08

J. Volkya


3 Answers

I stumbled on this when attempting to search for a solution.

Flash Player bug report WITH WORKAROUND

I haven't tested the workaround, but it should still work? Good luck.

Edit:

For anyone who can't/won't access the Adobe bug tracker, here is the workaround originally posted by Philippe Piernot:

var closed:Boolean = true;
var dummy:BitmapData;
dummy = new BitmapData(1, 1);

try
{
    // Try to capture the stage: triggers a Security error when the settings dialog box is open
    dummy.draw(stage);
}
catch (error:Error)
{
    closed = false;
}

dummy.dispose();
dummy = null; 
like image 150
Sam DeHaan Avatar answered Nov 08 '22 07:11

Sam DeHaan


call security panel ( like ns.addStream(mic))

            // WHEN PRIVACY PANEL IS ON MOUSE EVENTS ARE DISABLED
            stage.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
            function onMouseOver(e:Event):void { 
                trace("privacy panel closed");
                //REMOVE THE LISTENER ON FIRST TIME
                stage.removeEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
                //doStuff
            }
like image 24
csomakk Avatar answered Nov 08 '22 09:11

csomakk


I have resolved this issue in the next way:

private function showPrivacyDialog():void {
    var spr:Sprite = new Sprite();
    stage.focus = spr;
    spr.addEventListener( FocusEvent.FOCUS_OUT, handleFocusEvent );
    spr.addEventListener( FocusEvent.FOCUS_IN, handleFocusEvent );
    Security.showSettings( SecurityPanel.PRIVACY );
}

private function handleFocusEvent( event:Event ):void {
    event.target.removeEventListener( event.type, handleFocusEvent );
    const closed:Boolean = (event.type == FocusEvent.FOCUS_IN);
    trace( "Security Panel just", closed ? "closed!" : "shown!" );
    if (closed) {
        stage.focus = null; // or it can be restored to the previous value
    }
}

Check my full util class SecurityPanelUtil that shows settings dialog and then handle it close and notifies via callbacks immediately.

like image 35
Enhancer Avatar answered Nov 08 '22 09:11

Enhancer