Incorporating Flash into Your Web Pages

Everyone loves to add a little flash and pizzazz to their Web applications. Adding snazzy design pieces sometimes helps to break up seemingly monotonous page design and makes it graphically pleasing to the user . Macromedia's Flash is a popular multimedia choice frequently used on the Web today to accomplish this. Often you'll encounter sites that use intro pages, also known as splash pages, to introduce the site. These splash pages are commercial-like in nature and last a minute or two. Flash is the common tool to create intro pages and is a very easy tool to learn and deploy fantastic animated imagery for your business' site or any other e-media.

It's very easy to incorporate a Flash SWF file into Domino using a few HTML tags. You also can add the Flash SWF object to the database as a shared resource so that the code can point to it in Domino.

Using Script and HTML

The standard HTML script to get the Flash object to load into the Domino form, page, or subform is as shown in Listing 20.7. This example first calls the tag to set up the Flash file properties and load the associated codebase cab file. Microsoft Internet Explorer versions 3.0 and later use the CODEBASE attribute to detect which version of the Macromedia Flash Player ActiveX control is installed on a user's computer. If the user's version is earlier than the version specified by CODEBASE , Internet Explorer can automatically download and install the newer version of the Macromedia Flash Player from the location specified in CODEBASE .

Listing 20.7 Sample Script to Embed Flash in a Domino Page, Form, or Subform

macromedia.com/pub/shockwave/cabs/flash/ swflash.cab#version=5,0,0,0" width="466" height="233">

After the object's parameters have been set up, the object must be embedded in the page using the tag. This is the basic HTML code that is needed to run a Flash SWF in Domino. Other parameters can be set, just like an applet. You might want to visit www.macromedia.com to learn about these parameters and further support for Flash files.

JavaScript to Support Various Browser Types

Sometimes a developer is faced with having to support many browser versions and types. The code in Listing 20.8 shows you how to support Flash objects on all browsers that understand either JavaScript or ActiveX. If the browser supports the MIME type of application, the script writes out an EMBED tag to display the Flash animation; otherwise , it writes an IMG tag to display only a graphic. The OBJECT tag is invoked on any browser that supports ActiveX, regardless of which tag JavaScript writes.

Listing 20.8 Sample Script to Support Flash Objects in Various Browsers

macromedia.com/pub/shockwave/cabs/flash/ swflash.cab#version=5,0,0,0" width="466" height="233">

Make sure there are no line breaks in your EMBED or IMG tags, or the script will fail. If you'd like to use line breaks, put each line in a separate document.write() . Notice that the entire EMBED and IMG strings are enclosed in single quotes; this allows for double quotes to be inside the strings without breaking them or having to use a slash to declare each quotation mark ( " ). Figure 20.18 shows this code entered on a new page in Domino Designer.

Figure 20.18. The page and code as displayed in Domino Designer.

Domino will now be able to determine what mimeType the browser supports and can then either serve up the SWF or the graphic to the user. Figure 20.19 shows what the SWF looks like on the Web in Internet Explorer. The code for this example can also be found in the Chapter20.nsf database in the two pages named MyFlashMovie and MyFlashMoviewBrowserScript. Each contains its respective code.

Figure 20.19. Flash as displayed on the Web through Domino.

Using Domino's Shared Image Resources

If you look at the code a little closer, you'll notice that a was used in the object's and tags. The formula in this instance to create the computed value is @ReplaceSubstring(@Subset(@DbName;-1);"\";"/") . By also adding the SWF as a shared resource, you can access the file dynamically when called, along with using the instance inside the code to point to it. The file can be called two ways: explicitly as a shared image resource using the /myfile.nsf/myfilename.swf?OpenImageResource Domino URL command, or implicitly as a shared image resource using the /myfile.nsf/myfilename.swf Domino URL command. Both ways require that the file be uploaded as a shared image resource. replaces the myfile.nsf text in the code to make it dynamic. This technique can also be used to access any other shared resource in Domino.

Get the Latest Player

The latest version of the Macromedia Flash Player can be downloaded from www.macromedia.com/shockwave/download/download.cgi?P1_Prod_version=ShockwaveFlash.

Категории