Recipe 21.3. Detecting Flash Player Version


Problem

You want to detect the Flash Player version so you know that the user can view the published content.

Solution

Use the Detect Flash Version option in the Publish Settings dialog box, and then publish the .swf and .html files.

Discussion

When you publish SWF and HTML content from Flash 8, add Flash Player detection by clicking the Detect Flash Version checkbox in the Publish Settings dialog box. Unlike previous versions of Flash, the Flash 8 version detection script requires no additional files and pages aside from the standard SWF and HTML page. You don't have to write (or copy) complicated scripts. You don't have to manage lots of files. Selecting the Detect Flash Version checkbox in the Publish Settings dialog box automatically adds the necessary script to the published .html document.

Just below the Detect Flash Version checkbox, you can specify the minimum player version that you require. The major version is always the version of the SWF that you are publishing. For example, if you are publishing the SWF to Flash Player 8, the major version is 8. You can also specify minor version and incremental revision values if you want to require later player revisions. The Flash player detection script will test that the user has the required player version. If she does, the Flash content plays normally. If not, by default the user is presented with a basic HTML page that tells the user she must download a newer version of Flash Player to view the content. If you want to customize the alternate content, you can edit the following part of the HTML/JavaScript that is published in the HTML document:

 } else { // flash is too old or we can't detect the plugin   var alternateContent = 'Alternate HTML content should be placed here.'     + 'This content requires the Macromedia Flash Player.'     + '<a href=http://www.macromedia.com/go/getflash/>Get Flash</a>';   document.write(alternateContent); // insert non-flash content } 

The preceding code is the else clause of a JavaScript if statement. It runs only if the user doesn't have the required version of Flash Player. You can edit the code between the opening and closing curly braces ({}) so that it displays different content or so that it redirects to a different page.




Flash 8 Cookbook
Flash 8 Cookbook (Cookbooks (OReilly))
ISBN: 0596102402
EAN: 2147483647
Year: 2007
Pages: 336
Authors: Joey Lott

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net