9 Replies Latest reply on Sep 3, 2008 8:51 AM by abeall

    System dialogs and executing files

    abeall Level 3
      I'd like to know if I can do either of these things:

      1) Bring up a simple system modal dialog. Yes/No, Okay/Cancel, etc.

      2) Execute a file in it's default associated app... ie same thing as if user had double clicked the file. I want to open PDFs, DOCs, and PPTs in Reader, Word, and PowerPoint. Can't figure it out.

      If not, what is the best workaround?

      Last thing, I've mentioned this before, but I'm really itching for the ability to change the cursor. Hard to make an interface that involves resizing, panning, etc when you can't really change the cursor to reflect the action (I know the mouse hide workaround, but it has issues...)
        • 1. Re: System dialogs and executing files
          anirudhs Level 2
          Hi Aaron,

          True system level (preventing any other application from gaining focus) modal dialog's are not possible with AIR.

          However, a workaround (possibly annoying to the user) is using the makeWindowModal() at http://www.adobe.com/cfusion/communityengine/index.cfm?event=showdetails&postId=9963&produ ctId=4&loc=en_US

          With AIR 1.1, you can't execute a file in its default associated app. The closest thing you can do is a navigateToURL() which will open up a browser with that file from where the user can do "Open".
          • 2. Re: System dialogs and executing files
            abeall Level 3
            Thanks,

            makeWindowModal will actually work fine, thanks. True system level dialogs would still be nice when I don't want to have to create window content myself, but the ability to block the AIR app until resolution of a dialog is the main thing I wanted.

            Opening the file is a bit more of a problem. The file types I'm trying to open are PDF and PPT. I've been toying with navigateToURL. PDF works fine, since the browser usually has Acrobat Reader anyway and doesn't prompt anything. But PPT is not fun.

            I know AIR is only version 1, but I was a bit surprised that it behaved this way, opening a client browser. As I understand, AIR is a runtime that runs web technology, ie it's basically a browser. Why would navigateToURL not be captured and handled by AIR, then?

            Full execution of external apps I can live without, but I really need some APIs for basic stuff, like opening a file in its associated app. Is there a roadmap to fix this issue? After some research it seems to be a very common criticism.

            Would it be possible to navigateToURL an HTML page which opens the file and closes itself?
            • 3. Re: System dialogs and executing files
              anirudhs Level 2
              quote:

              Would it be possible to navigateToURL an HTML page which opens the file and closes itself?

              No, the browser handles that and those features are not exposed to scripting from javascript.

              "Opening a file using the default application" is something I'm sure that the AIR team definitely knows of as a popular feature request. Though I will be passing along your feedback.
              • 4. System dialogs and executing files
                Damon Edwards Level 3
                When opening PDFs, you can use this to open the PDF directly if they have the appropriate version:
                var url:URLRequest = new URLRequest("some.pdf");
                if(HTMLLoader.pdfCapability == HTMLPDFCapability.STATUS_OK){
                var pdfLoader:HTMLLoader = HTMLLoader.createRootWindow(true, null, true, new Rectangle(x, y, width, height));
                pdfLoader.width = width;
                pdfLoader.height = height;
                pdfLoader.load(url);
                };

                http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/html/HTMLLoader.html#creat eRootWindow()
                • 5. Re: System dialogs and executing files
                  abeall Level 3
                  Thanks, anirudhs.

                  dzedward, thanks, that's very fascinating. So, if I understand, Using HTMLLoader.createRootWindow()/load() I'll be able to load a PDF in an AIR window and control the window rather than be at the mercy of the system/browser? This is great, that means I can control and capture when the window/PDF is closed, which is something that wanted. Now, is there any chance I could tell the PDF to print, also?

                  And as for PPTs... what happens if I use the method you posted but point to a PPT, does an Open/Save dialog appear without the system browser?

                  And if I point HTMLLoader.load() to a .swf, is that the same as what AIR does when your application root content is set to an .swf file? If so, that's great news... developing in Flash CS3 I have not found a good way to launch a predefined window. In the past I created a new NativeWindow then used Loader to load in an swf to the stage. It was very awkward.

                  I'm going to experiment with HTMLLoader.createRootWindow() and load(). Thanks!
                  • 6. Re: System dialogs and executing files
                    Damon Edwards Level 3
                    Thats a good question, in the case where I've used the HTMLLoader, I've set up a case statement where if the pdfCapability didn't resolve to STATUS_OK, I just open a save dialog... I'll have to test it out as well. I do know that, if you use, lets say, www.adobe.com, instead of "some.pdf" it will load the html like a browser window using WebKit, and you can follow links and so on.. Basically like any other browser...
                    • 7. Re: System dialogs and executing files
                      abeall Level 3
                      Okay, here are my findings:
                      1) PDF loads as you describe, and I can control the window, including capture the close event, which is significant for my situation...
                      2) Passing in a URL to a PPT creates the window, but nothing loads in the window and no save/open dialog appears. This is very unfortunate. Add this to my ER, anirudhs: some way to capture requests that can't be opened in AIR and display an AIR dialog to resolve the situation. Since it would be an AIR dialog it could allow the developer to customize the dialog, any combination of open/save, set default save location or open with app, automatically open/save, display a generic error message, etc. It's all related, I suppose.
                      3) The PDF contents in the new window (HTMLLoader) seem to always load at a certain size, despite what the window size is set too. Once I resize the window the PDF contents snap to fill the window. It's very odd... have you seen this behavior?

                      I think I'll explain exactly what I'm trying to accomplish:
                      1) The user is given an interface to select from many PDF, PPT, and FLV documents.
                      2) The user orders the documents as desired.
                      3) The user enters into a presentation mode in front of a live audience, showing each document one at a time (each document may contain many pages, of course)
                      4) Ideally, the client wants this to be automated. So the first document loads, the user manually moves through it, and once they are finished with the document and close it, the next document automatically opens. You can see why HTMLLoader for PDF is perfect for me, now I can capture the close event and proceed automatically. For FLV the player is in AIR/Flash of course, too, so I have control there. PPT is where a wrench gets thrown into the turbine and the flow comes to a grinding, awkward halt, unfortunately. To make matters worse, the user base is not very computer literate. I don't think a browser being launched and an Open/Save dialog is going to pass.

                      At the moment I'm regrettably looking into what it would take to convert all PPTs to SWFs or PDFs. It would have to happen on the server, too, as the content is managed by an admin.

                      You've both been a great deal of help, any further suggestions on how I should approach the rest of this would be welcome.

                      Thanks.
                      • 8. Re: System dialogs and executing files
                        Damon Edwards Level 3
                        Yes, I do see how that can throw a wrench into the situation... I dont have much experience dealing with power point, but I have the sneaking suspicion that you won't be able to open the document, and if you do, won't know when the document is closed.. I've read about shu-player which is basically like jugglor for AIR, which allows you to execute other programs, this might be a solution, however, I'm not sure if it allows you to listen for a close event of a power point presentation....
                        • 9. Re: System dialogs and executing files
                          abeall Level 3
                          I looked into Shu, which looks great in many ways, unfortunately they seem to have a problem with AIR distribution licensing... also it would not provide a good installation process like we planned. Certainly a good product we will keep an eye on, though.