To better understand all that is involved in the programming of crossapplication extensions, you need to have a firm grasp of the user experience. When you understand the end result, the reasoning behind the coding process becomes much clearer. NOTE Cross-application extensions are found listed under the Commands menu; however, the Extension Manager can install them wherever the author deems appropriate. You can access the Fireworks Button object, for example, through Media it's own categoryin the Insert panel. Running the Command: The User ExperienceLet's step through a sample command. Although the following example uses screen shots from the Convert Text to Image command, the basic procedure is the same for any such extension:
TIP One of the cool features of the Convert Text to Image command is the swatch that shows an example of the selected Fireworks style. These swatches are actually created programmatically from within the extension by pressing the Update Styles button. Depending on the complexity of the command and the speed of the system involved, the whole procedure might happen so fast that the user is not aware of all of these steps. All that the end user really has to do is click the OK button. The programmer's task, as you'll see, is a tad more complex. Now, let's pop that hood and see what's really going on. TIP You can customize the processing message by changing the App.batchStatusString property when you execute the Fireworks command. To see this effect in action, select Update Styles from either the Convert Text to Image or Convert Bullets to Image commands. Behind the Scenes: The Developer's ExperienceThe biggest problem in creating cross-application extensions is one-way communication. Although Dreamweaver (through the FWLaunch DLL) is clearly able to send a command to Fireworks for execution, Fireworks cannot, in turn , talk to Dreamweaver. Rather, Dreamweaver must wait for a response to its request to Fireworks before it can continue processing. This restricted communication is the rationale behind the code workflow found in cross-application extensions. You might be surprised to find that such an application typically involves a minimum of five different JavaScript files. Let's look at an overview of how the process works, from the coding perspective. You might find it helpful to refer to diagram 7.4. Figure 7.4. The cross-application extension workflow from a code point-of-view .
NOTE Dreamweaver commands may be split into two or more files within the Commands folder, an HTML file and a JavaScript file. The HTML page holds the form and form elements that make up the dialog box as well as <script> tag linking to the JavaScript file. The JavaScript file contains most, if not all, of the JavaScript functions necessary. This file often also defines text strings in a series of global variables to make localization easier. All of Macromedia's commands use the two-file design. Although this whole procedure might appear quite convoluted, it's actually fairly straightforward to implement. With the standard Macromedia files (FwExec.js, FwExecDlg.htm, and FwExecDlg.js) in place, all the back-end interprocess communication is handled for you. As a programmer, you can concentrate on coding the commands to execute in Fireworks and Dreamweaverand you'll find an example of how it's done in the next section. |