showSettings callback in Flex?

I am pretty new to flex, so forgive me if this is an obvious question.

Is there a way to open the Security.showSettings (flash.system.Security) with a callback? or at least to detect if it is currently open or not?

My flex application is used for streaming audio, and is normally controlled by javascript, so I keep it hidden for normal use (via absolute positioning it off the page).

When I need microphone access I need to make the flash settings dialog visible, which works fine, I move it into view and open the dialog.

When the user closes it, I need to move it back off the screen so they don't see an empty flex app sitting there after they change their settings.

thanks :)


If you do something like this, it will work in some situations:

var mic:Microphone = Microphone.getMicrophone();
mic.addEventListener(StatusEvent.STATUS, onMicStatus);

If you are just trying to use the microphone and relying on Flash to pop up the dialog to ask the user for permission, Flash will open a dialog with two buttons, Allow and Deny. When the user clicks one of the buttons the StatusEvent will fire, the dialog will close, and you can move the flex app out of the way.

If you are manually opening the settings panel (via Security.showSettings), you get the panel with Allow and Deny radio buttons, and the event will fire when the user clicks on the radio buttons, not when they close the panel, which is probably of less help to you.

Update: flex 4 solution

So when I moved to the flex 4 and started compiling my mxml with adobe's open source mxmlc compiler, the solution below no longer worked because the alert doesn't lose focus when you're in the settings anymore.

As far as I could tell I had to move to a less elegant solution where the user must click "OK" on the alert box every time they are done with the settings.

Here is the new code:

private function setup_smart_hide():void {
    // Call this function whenever you make the flex app visible (or add it
    // to a show_flex() function if you have such a thing set up)
    alert ='Click "OK" to continue.', 'Thanks!', Alert.OK, null, function(e:CloseEvent):void {

        // calls the external javascript to hide the flex app


OLD: (flex 3) Got this working...

private function setup_smart_hide():void {
    alert ='Thanks');

    alert.addEventListener(FocusEvent.FOCUS_IN, function(event:FocusEvent):void {
            // javascript to hide the flex app"SB.flex.hide");
    alert.addEventListener(FocusEvent.FOCUS_OUT, function(event:FocusEvent):void {
            // javascript to show the flex app"");


Which is run first thing in the init() function... the only problem is (like Wesley said), the focusOut event occurs when the flex app itself loses focus as well.

Need Your Help

Are there alternatives to UltraWinGrid?

c# infragistics ultrawingrid

I've been using the Infragistics UltraWinGrid for a while in a C# project, and while it's very spiffy, it is sometimes a bit heavy to run (and editing it in Visual Studio can be hazardous).

Optimal / best pratice to maintain continuos connection between Python and Postgresql using Psycopg2

python linux performance postgresql out-of-memory

I'm writing an application in Python with Postgresql 8.3 which runs on several machines on a local network.