Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><s>The "Open with..." dialog on Windows shows whenever you try to launch an application that does not have an associate file type. Launch the application with NativeProcess.start() and Windows will take care of either opening it with the correct program, or presenting a selection screen if there is no file type associated.</p> <p>Alternatively, depending on what you are trying to do, you may be interested in associating file types with your AIR application. For instance, you can associate PNG files with your AIR app so that they will by default open in your AIR app (e.g. double-clicking a PNG file will launch your app with an INVOKE event specifying the PNG file that was opened). See <a href="http://livedocs.adobe.com/flex/3/html/help.html?content=File_formats_1.html" rel="nofollow">http://livedocs.adobe.com/flex/3/html/help.html?content=File_formats_1.html</a> under "Declaring file type associations" for more information.</p> <p>Of course, your AIR app may have no capabilities to handle opening whatever file you are trying to open and you want a different program to handle it, in which case you can just use the first method which will let the operating system take care of launching the application with the correct program.</s></p> <p><strong>EDIT :</strong> </p> <p>I got confused as to what Native Process actually does. NativeProcess launches executables - NOT files, so the method above won't work.</p> <p>Instead of trying to open the file directly with NativeProcess, try opening the program that you want to open the file with and pass the file in as an argument. For instance, if you want to open a PNG file with some special image program, you would do something like this:</p> <pre><code>var imageEditorProgram:File = new File("C:/Path/To/Program.exe"); var args:Vector.&lt;String&gt; = new Vector.&lt;String&gt;(); args.push("C:/Path/To/Image.png"); var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo(); nativeProcessStartupInfo.executable = imageEditorProgram; nativeProcessStartupInfo.arguments = args; var nativeProcess:NativeProcess = new NativeProcess(); nativeProcess.start(nativeProcessStartupInfo); </code></pre> <p>This should open the image editing program with the image file passed in.</p> <p>However, the downside with this method is that you can't just let the operating system determine which program to open the file with. You should be able to open a file browse dialog and allow the user to select the program to open the file with (similar to how the operating system does it). So, hopefully the following would do what you want:</p> <pre><code>var file:File = File.userDirectory; file.addEventListener(Event.SELECT, selectHandler); file.browse(); private function selectHandler(e:Event):void{ file.removeEventListener(Event.SELECT, selectHandler); var filePath:String= file.nativePath; var imageEditorProgram:File = new File(filePath); var args:Vector.&lt;String&gt; = new Vector.&lt;String&gt;(); args.push("C:/Path/To/Image.png"); var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo(); nativeProcessStartupInfo.executable = imageEditorProgram; nativeProcessStartupInfo.arguments = args; var nativeProcess:NativeProcess = new NativeProcess(); nativeProcess.start(nativeProcessStartupInfo); } </code></pre> <p>I haven't tested the above code, but it should open a file browse dialog allowing the user to select a program to open the file with (perhaps you should add a FileFilter to restrict the user to selecting only .exe), and then launch that program using NativeProcess.</p> <p>For user-friendliness you should consider saving user preferences for filetypes (so instead of forcing them to go through the file browser every time they want to open a PNG, just remember that they like to open PNG's with AwesomeImageEditor.exe).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload