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.
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;
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
}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With