next up previous contents
Next: Opening system dialog boxes Up: Tutorials Previous: Accessing disk files   Contents

Launching external applications

SWFKit provides two ways to launch an external application. One way is to use the "exec" command, and the other way is to call the "Shell" object.

The "exec" can be used either synchronously or asynchronously. To use it synchronously in action script:

function runApp(args)
{
    ExternalInterface.call("exec", args);
}

runApp("notepad.exe c:\\1.txt");
To use it asynchronously
fscommand("exec", "notepad c:\\1.txt");
The "exec" can launch an external application at anywhere on local disk. If you pass the absolute path name of an application to the "exec" command, it will launch it directly; if the relative path name of an application is passed to it, it will first search for the application and then launch the application. It searches for an application in this way: first, searches in the resource files, if found, launches the application and returns; second, searches in the same folder of the .exe file, if found, launches the application and returns; If still not found, it will search in the system directory and the directories listed in the "PATH" environment variable.

The "Shell" object provides more powerful methods to launch an external application or open an external document. The "run" method can launch an application and return a Window object that represents the main window of the running application. The "open" method can open an external document. The "runAndWait" method can launch an external application and wait for it to exit. The following code shows how to use the Shell object in action script in Flash 8

import SWFKit.*;

var window = Shell.run("notepad.exe c:\\1.txt");
Dialogs.msgBox(window.caption);


next up previous contents
Next: Opening system dialog boxes Up: Tutorials Previous: Accessing disk files   Contents
Copyright ©2000-2010 Shanghai TopCMM Software Technologies. All Rights Reserved.