Flash Plugin Detection

Charlie R. Claywell
Screenshot of notification to download Flash Player
Screenshot of notification to download Flash

When you're building a site or web page that incorporates Adobe Flash, you need to include coding that determines if the user has the plug-in installed, and if so, which version is being used. Several methods of doing this have been used, but the SWFObject approach has become the standard.

What Is SWFObject?

Beginning with its CS4 products, Adobe adopted the SWFObject approach for embedding Flash content into an HTML page. The approach replaces the earlier methods of Adobe Flash Player Detection Kit, SWFObject 1.5 and UFO.

The latest version of SWFObject, 2.0, is an ongoing attempt to unify all the existing Flash Player embed methods while creating a web standard, browser-compliant approach that can be used across all operating systems and browsers.

How It Works

The method works by using markup language and JavaScript to deliver the Flash content or to display alternative content when Flash is not present. The two approaches used inside this system are the static and dynamic publishing methods.

  • Static publishing embeds both Flash content and alternative content using standards compliant markup, while using JavaScript to resolve the issues that markup cannot solve. One of the critiques of this method is that it does not alleviate the Click to Activate issue associated with the Internet Explorer 6/7 and Opera 9+ browsers.
  • This issue is resolved in the dynamic publishing approach. This method, which is similar to previous versions of SWFObject and UFO, essentially bypasses the issue through the use of additional JavaScript.

Creating the Code

Although anyone with an understanding of JavaScript can hand code it, but it's more efficient to use a code generator. A designer's specific needs for his or her Flash content can be selected by using the generator's drop down menus.

Getting Started

Before creating the coding, you will need some files and the generator. Get these by:

What the Files Do

When you extract the SwfObject 2.2 zip file, you will find a handful of swf, js, and other example files. The two files you need are expressInstall.swf and swfobject.js. If you include expressInstall.swf in your site's directory, it will allow the user's Flash player to update to the correct version from within the browser when he or she visits your page, provided the user already has a lower version of Flash installed.

The JavaScript file does all the heavy lifting in this system by loading the Flash content into the user's browser.

Screenshot of Generator
Screenshot of Generator

Using the Generator

  1. Open the generator using Air.
  2. Choose either static or dynamic publishing.
  3. Set the version of Flash required for your content.
  4. Input the name of your Flash file inside the SWF definition box.
  5. Fill out the dimensions of the Flash file.
  6. Create a name for the Flash Content ID. The generator will create a JavaScript variable based on this ID so the content can be accessed and controlled by the JavaScript file.
  7. Click on more to adjust and set any parameters or attributes, such as setting a background color or whether to auto play or loop the Flash movie.
  8. Once all variables are set, make adjustments to the HTML definitions, if desired.
  9. Click on Generate.

Using the Code

Once the code has been created, copy and paste the content inside your HTML page and place the coding calling out to the swfobject.js between the tags like this: .

Alternative Content

When Flash is used, it's standard coding practice to include alternative content for users that do not have the Flash player installed on their machine. The default alternative content pre-loaded by the generator is coding to display the "Get Adobe Flash Player" image. You can keep that content or alter it to best suit your needs.

Mobile and Flash

Displaying Flash on mobile devices is one dilemma that SWFObject cannot address since the format is not supported by Apple and even Adobe abandoned support for Android devices a few years ago. So, if your site will target a substantial mobile audience, avoid Flash and use HTML5 technologies to deliver your media-enriched content.

Flash Plugin Detection