J. Volkya
J. Volkya

Reputation: 1000

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.

Upvotes: 12

Views: 6912

Answers (4)

Enhancer
Enhancer

Reputation: 61

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.

Upvotes: 6

henke37
henke37

Reputation: 17

The panel is secretly rendered using Flash's own display engine. To do this they secretly add the panel to the display list of the stage.

You can detect this by checking if stage.getChildAt(stage.numChildren-1) equals null. That's an otherwise impossible scenario that reveals the existence of the panel.

Upvotes: 0

csomakk
csomakk

Reputation: 5497

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
            }

Upvotes: 12

Sam DeHaan
Sam DeHaan

Reputation: 10325

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; 

Upvotes: 13

Related Questions