Accessibility
Bobby van der Sluis

Bobby van der Sluis

Refunk
bobbyvandersluis.com

Table of Contents

Created:
15 October 2008
User Level:
Intermediate, Advanced
Products:
Flash Player

Detecting Flash Player versions and embedding SWF files with SWFObject 2

SWFObject 2 offers multiple standards-friendly methods to embed SWF files into web pages. It uses JavaScript to detect Flash Player and avoid broken SWF content, and is designed to make embedding SWFs as easy as possible. It supports the use of alternative content to display content to people that browse the web without plug-ins, to help search engines index your content, or to point visitors to the Flash Player download page. SWFObject 2 detection is future-proof, includes Adobe Express Install, and offers an elaborate API for JavaScript developers. All of this is powered by one small (under 10K) JavaScript file.

No matter if you are an HTML, Flash, or JavaScript developer, SWFObject 2 has something in it for everyone. It offers two distinct methods to embed SWF files, both with a different underlying development philosophy:

  • Static publishing uses markup to embed both SWF content and alternative content, and utilizes unobtrusive JavaScript to resolve a series of issues that cannot be solved with markup alone. It promotes the actual authoring of standards-compliant markup and will therefore especially appeal to web standards developers.

    Its main advantage is that the mechanism of embedding SWFs relies solely on the object element, so your content can reach a significantly bigger audience than publishing methods that rely on a scripting language. Its biggest disadvantage is that it doesn't offer a workaround for click-to-activate mechanisms in Internet Explorer and Opera imposed by active content. The good news is that Microsoft and Eolas have settled their patent dispute, with the result that active content has already been phased out from most Internet Explorer browsers, so only a very small percentage of visitors will be affected by it.

  • Dynamic publishing uses markup to define alternative content only and utilizes unobtrusive JavaScript to replace this with the SWF if the minimal Flash Player version is installed and sufficient JavaScript support is available. It comes in two flavors: an easy-to-use full automatic method similar to SWFObject 1.5 and UFO that will appeal to many existing Flash developers, and a bare-bones JavaScript API method that is aimed at the more hardcore JavaScript and AJAX developers.

    Dynamic publishing avoids click-to-activate mechanisms by its nature, is less verbose than static publishing and integrates very well with scripted applications. Its biggest disadvantage is that embedding SWFs does also rely on JavaScript, resulting in a smaller coverage than when using static publishing.

SWFObject 2 is an open-source project by Geoff Stearns, the late Michael Williams, and myself. It is the successor of SWFObject 1.5, UFO, and the Adobe Flash Player Detection Kit. SWFObject 2 aims to unify all existing Flash Player embedding methods and provide a new standard for embedding Flash Player content.

Requirements

To complete this tutorial you will need to install the following software and files:

Flash Player 9 or later

SWFObject 2

Code editor of choice


Sample files:

Prerequisite knowledge

You should have a basic understanding of the Flash authoring tool, HTML, and JavaScript.

Creative Commons License
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License

About the author

Bobby van der Sluis works at Refunk, an award-winning creative agency based in Amsterdam, The Netherlands, that specializes in Adobe Flash. He is a big fan of both web standards and Adobe Flash, and occasionally has the urge to write about these topics on his personal website or for online magazines. He is the creator of UFO and coauthor of SWFObject 2—two well-known, open-source JavaScript libraries for detecting Adobe Flash Player and embedding SWF files into web pages.