SWFObject

Written by: Pawel Rembisz in Product Reviews, Web Technology

What is SWFObject?

SWFObject is a JavaScript Flash Player detection and embed script.

Some Background

Embedding Flash objects into an HTML website became a whole lot more difficult when Microsoft lost a lawsuit to Eolas Technologies over a patent for how media players such as Flash, QuickTime and many others are added to a website. Because of this, any media using the Eolas ActiveX plugin needed to be activated (usually via a click on the content – whether it’d be a Flash banner or movie) before the content could be viewed. This was very unfortunate for Internet Explorer and Opera users and especially disturbing to all the developers who needed to ‘fix’ that annoying issue.

The Solutions

A number of solutions came out that used JavaScript to fix the ‘click-to-activate’ nuisance, but most of them where not very pretty and definitely not easy to implement, especially for some of the more dynamic websites. Eventually, the complex solutions were dropped and the better ones were merged. SWFObject was one of the better solutions.

THE Solution

One of the better Flash content embed methods was developed by DeConcept, (later improved upon and combined with UFO and the Adobe Player Detection Kit, which now has its own Google Code page), and named “SWFObject”.

SWFObject greatly simplifies the process of embedding Flash content into websites by providing a simple function that handles all the necessary parameters, content activation code and even comes with its own code generator. SWFObject is more optimized and flexible than any of the other Flash Player embedding methods around and it promotes the use of web standards and uses unobtrusive JavaScript and its other best practices.

SWFObject also provides a Flash Player detection method which prompts the user to update their Flash Player if it is out of date with an easy one-click installation. If no Flash Player is detected, the user is presented with alternative content. This is a big plus when it comes to SEO (Search Engine Optimization) as most Flash websites are not indexed by search engine spiders. With alternative content, web spiders can crawl that content and index it.

Another great tool that comes with SWFObject is the code generator. The code generator allows you to easily set up your Flash embed code without even writing a line of code!

Useful Resources:

SWFObject Website

http://code.google.com/p/swfobject/

Deconcept

http://blog.deconcept.com/swfobject/

Adobe (Marcomedia)

http://www.adobe.com/devnet/flashplayer/articles/swfobject.html