Embedding Flash content into a web page seems simple and in theory, it is.

But if you’re using embed/object tags alone to embed Flash content, potential issues lurk under the surface.

As Bobby van der Sluis at A List Apart explains, a simple implementation of the embed/object tags alone isn’t perfect.

Fortunately, the techniques of a solid embedding method can be found in SWFObject 2, a JavaScript that is used to embed Flash content.

As per the documentation, SWFObject 2:

  • Detects the Flash Player version a user has installed and determines whether to show Flash content or alternative content.
  • Doesn’t require vendor-specific markup.
  • Implements standards and best practices.
  • Can eliminate the “click-to-activate” requirements that some browsers (notably certain versions of Internet Explorer) have due to the Eolas patent.
    Will replace the current official Adobe Flash Player Detection Kit in a future version of Flash.

To get started with SWFObject 2:

  1. Download the code from Google Code.
  2. Place the SWFObject 2 file in a directory that is accessible by your website’s web pages.
  3. Include the SWFObject 2 JavaScript file on the web pages that will use it. Example:

  4. Decide whether to use the static publishing or dynamic publishing methods that SWFObject 2 offers. The documentation details the advantages of both.

    Because I typically use SWFObject 2 to remove any Internet Explorer “click-to-activate” requirement and I know that the most of the visitors to my websites have JavaScript enabled, I tend to use the dynamic publishing method but your needs may make the static publishing method more appropriate.

  5. Follow the instructions on the SWFObject 2 documentation page to embed your Flash content in a web page using the method you’ve chosen.

There’s a nifty video tutorial for SWFObject 2 at gotoAndLearn.com and if you run into any problems, there’s a group on Google Groups that may also be of help.

Happy embedding!