[ LiB ] |
You've seen how complex Flash content, including interactive movies, can be inserted into HTML pages within Dreamweaver. The Flash Button and Flash Text objects (available in the Media menu of the Common category of the Insert bar) enable you to create, customize, and insert simple Flash-based page elements (buttons and text) into a web page without ever leaving Dreamweaver, and without having to own or know how to use Flash (see Figure 16.20). This opens all sorts of new horizons for integrating different kinds of Flash content in your websites quickly and inexpensively.
The technology that makes Dreamweaver-created SWF files possible is Macromedia Flash Generator. Generator is a software system for creating Flash graphics dynamically from changing information in a database, similar to the way ASP and ColdFusion create text and page layouts dynamically. To work with Generator, the Flash author creates a special SWT (small web template) file , which is essentially a SWF file with placeholders for collecting and displaying dynamic data. When the page is uploaded to a web server, as visitors access it, the Generator application server, which sits on the server, creates SWF files to display on the page by filling in the SWT placeholders with data from a server-side database.
Using Generator technology, Dreamweaver creates Flash Text and Flash Button objects from SWT files stored in its Configuration folder. Whenever you choose one of the Flash objects from the Insert bar, Dreamweaver collects information from you (text to enter, typestyle, and so on), feeds that information into placeholders in one of its SWT files, and generates a SWF file. Figure 16.21 shows an overview of the whole process.
You create Flash buttons and text at the same time as you insert themby clicking the Flash Button or Flash Text object in the Insert bar. When you click the object, a dialog box displays, enabling you to customize the button or text that will be created. When you click OK to exit the dialog box, the SWF file is created and the object is inserted.
Figures 16.22 and 16.23 show the dialog boxes for the Flash Button and Flash Text objects. They give you similar choices for specifying type, color , and linkage. The Flash Button dialog box also enables you to choose a button style.
When you insert a Flash button, Dreamweaver creates a SWF file based on one of a dozen or more SWT templates. Each template contains the graphic elements for a different button. In this dialog box, each SWT template is shown as a separate button style. The graphic appearance of the button styles (color, shape, decorations, and so on) is not customizable because this information is built into the SWT. Any rollover effects also are built into the button style and can't be edited here.
To get more button styles from the Macromedia Exchange, click the Get More Styles button in the editing dialog box. This launches your browser and connects you to the Exchange (if your computer is connected to the Internet). When at the Exchange, navigate to the Flash Media category of extensions to see currently available buttons and other Flash- related extensions. Each set of button styles is saved as a Macromedia Extension Package (MXP) file, ready for use with the Extension Manager.
If you're inserting Flash text, or if the Flash button style you're inserting includes a text label, you can determine what text will appear and how it will be formatted. Note that because fonts are automatically embedded in all Flash movies, you can set the typeface to any font installed in your system. This font then becomes part of the SWF movie.
If you want your Flash objects to contain any links, you need to assign the link information in this dialog box. The link then becomes part of a getURL() command in the generated SWF file. This is because, unlike images and text, media objects cannot just be wrapped in an <a> tagso you can't use the Property Inspector to assign links. (For more on links and targets, see Chapter 6, "Links and Navigation.")
Like pixel images, Flash content always exists inside its own rectangle. This means you'll need to assign it a background color that matches the color of whatever it will be sitting on (page, table cell , layer, and so on). The following tips apply to assigning background colors:
Color sampling works here like it does throughout Dreamweaver. To match your web page's background color, just position the Flash object dialog box so that you can see some portion of your document behind it, and then click the color swatch; when the eyedropper cursor appears, click to sample the page or other desired background color.
Background color is not just for Flash text! Even for rectangular Flash buttons, you want to assign a background color, unless you want your button to be surrounded by a little white halo on the page.
Although this will have an effect only when seen in IE/Windows, you can use the wmode parameter to make the background invisible. After you've exited the dialog box, select the Flash object and use the generic Parameters dialog box from the Property Inspector to assign wmode=transparent .
Note that the dialog box offers only limited preview capabilities as you're creating the SWF. You can preview in general what a button style will look like, but other than that, you have no visual feedback as you're working. This is because, as you're making your choices in the dialog box, Dreamweaver has not yet created the SWF file it will be inserting, so there's nothing to preview. If you're using the dialog box to create a new Flash object, instead of editing an existing one, you can't even use the Apply button to see your changes in the Document window because Dreamweaver can't apply changes to a SWF that it hasn't created yet. For this reason, creating Flash Button and Text objects usually involves several trips to the editing dialog box.
After it is inserted, the Flash button or text is coded into your HTML the same way that any SWF file would be, using object and embed tags. Just like any Flash movie, you can assign any of the parameters listed in Table 16.1. By default, Dreamweaver assigns Flash Text objects a scale value of exactfit , allowing nonproportional scaling. Unlike standard Flash movies, the movie contents are always visible in Dreamweaver Design view, so you don't have to use the Property Inspector's Play button to preview them. This makes resizing more intuitive because you don't have to stop the playback before using the object's resize handles. Here are a few other things to consider when working with these Flash objects.
You edit a Flash Button or Text object by going to the Property Inspector and clicking the Edit button or by double-clicking the object itself. Either method reopens the original Flash object dialog box, ready to accept customization changes. Be aware that because SWF files can't be edited after creation, when you open the dialog box, make changes, and click OK, Dreamweaver is generating a new SWF, not editing the existing one. If you change the name in the Save As input field, you'll generate a separate SWF. If you leave the name the same, you'll overwrite the original SWF.
Again, because Dreamweaver is creating SWF files as it goes, you can't use Edit > Undo or the History panel to undo edits made to Flash text or buttons. It makes sense when you think about it: When you perform your edits, Dreamweaver creates an uneditable SWF file and saves it to your hard drive. Because that file is not editable and is already saved, there's nothing to undo. The only way to undo changes to Flash Text and Button objects is to reopen the editing dialog box and manually change things back to the way they were.
It's an obvious statement, but one worth repeating: Flash objects are resizable. Have a blast, with no worries about losing image quality if you scale up an object.
After you've created a Flash object, you can, of course, duplicate it as you would any page element (copy and paste, or Option/Ctrl-drag). Be aware, however, that each duplicate is an instance of the same SWF file. To change the text, color, link information, or other embedded properties in a Flash object, you'll need to tell Dreamweaver to generate a new SWF file instead of replacing the original. The procedure is as follows :
Every program has its own way of handling dragging to duplicate. To Ctrl-drag in Dreamweaver/Windows, click the Flash button and hold down the mouse button until the cursor changes to an arrow with a dotted square. Then press Ctrl, and a plus sign (+) will appear in the square; then drag. If you don't wait for the cursor change, the duplication might not work. |
It's time to create yet another Art Gecko home page! This time, you'll use gecko_banner.swf for the top banner, but you'll create your own navigation sidebar from Flash Button objects. Then you'll dress up the text headings by replacing them with Flash Text.
When duplicating Flash text or buttons, it's crucial to change the filename in the Save As Input field. If you don't remember this step, you'll be changing the original SWF file you duplicated from. |
What if you want to use your Flash Button or Text object not as a standard link, but as a link that triggers a JavaScript action? You can't just select a Flash object and assign a behavior to it, as you would with regular text or images, because in HTML, the object and embed tags don't accept event handlers. (See Chapter 15 for more on this.) JavaScript links, like other links, must be embedded in the Flash file itself.
If you read the earlier section on sending JavaScript out of Flash movies, however, you already know that it's possible to embed a JavaScript command in a Flash link. Therefore, just as you can add links to Flash Button and Text objects, you can add JavaScript links. You just use the javascript: keyword, followed by whatever command you want to execute. The Flash Button dialog box shown in Figure 16.25, for instance, creates a button that opens an alert window with the message "Hello, world!"
This is fine if you like writing short little JavaScript statements by hand. To execute more complex scripts, write the code as a function in the document head and use the previous technique to embed the function call in the Flash object.
By following the procedure described in Chapter 13 for "hijacking" behavior function calls, you can even use the Flash object to trigger a Dreamweaver behavior, adding complex scripting functionality to your Flash object with minimal coding on your part. The steps are as follows:
Figure 16.26 shows a Flash button configured to call the Open Browser Window behavior function.
[ LiB ] |