2 Replies Latest reply on Aug 3, 2011 3:25 AM by _spoboyle

    How to close File Dialog browseForOpen


      Hi All,


      I am new to Flex. I am developing a Air Application using Flex Sdk 4.5.


      I have a file dialog to select afile-


      var sendFile:File = new File();

      var filefilter:FileFilter = new FileFilter("*.*","*.*");

      sendFile.browseForOpen("Send file",[filefilter]);


      I have a  Login and Logout in option in my application so when User got signout I closes all open windows within my application other the the Login Screen but I am unable to close the BrowseForOpen file dialog as I donot have the dialog handle to close it.


      So please help me out how should I close BrowseForOpen dialog from my Air App.




        • 1. Re: How to close File Dialog browseForOpen
          blazejewicz Level 4



          native dialogs are modal. So they are blocking user interaction (mouse/keyboard/touch) untill dialog is dismissed - by user - not via code. Tha'ts assumed that showing dialog is part of user action and part of current workflow - and they have specific task in mind. There is no easy way to close them as there is no access to them other to showing them on screen (what about moving them? or resizing? or providing information of display mode as there could be many different display modes on modern OS sometimes more suited to select image then text file) - and there is no method in file.filesystem.FileReference/file.filesystem.File for it.

          If your dialog is shown as result of user action - it should be up to user to dismiss it or fill it with data (here with path(s) to content files). It is also presumed that showing that dialog - as routine - is part of other task/routine in your application (you're expecting to get files from user input for some reason). And that task should persists. Your application is free to change its other states in the background - as dialogs in Air SDK are non-blocking/asynchronous - so for example your login state in application can be updated without interupting given/pending task - which was delegate to user to complete.

          (if you showed dialog without user interaction - which is possible in Air runtime - then that is UI desing flaw if you're expecting possible transition to other application state - as there could be no user around your machine at all for long time to use that dialog - or she/he could be doing something different in application beign interrupted by dialog)


          If you're having issues with multiple-windowed air application when one window is displaying modal dialog (to that given window) but window is hidden - see comments on docs:

          http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filesystem/File.h tml#browseForOpen()



          kind regards,


          • 2. Re: How to close File Dialog browseForOpen
            _spoboyle Level 4

            I had the same issue and I couldn't find a good way to do what you are trying to achieve, best thing to do is disable the logout option until the user selects a file


            another hacky option is


            for each (var window:NativeWindow in nativeApplication.openedWindows)
                 if (!window.closed)