Lab: SWFObject
SWFObject 2 Examples
SWFObject is a non-obtrusive method of embedding a Flash SWF onto a web page. It's standards-compliant, keeps your markup clean, uses simpler embed code than the traditional Adobe code, and bypasses the EOLAS "click to activate" issue in Internet Explorer. In short, it's very cool.
This page originally contained examples I created in response to postings at the old SWFObject forum, which supported SWFObject 1.5 and older. With the release of SWFObject 2.0, I've moved the old examples here and created a whole new set of SWFObject 2.x examples.
Important note: SWFObject 2.x uses completely different syntax than SWFObject 1.x; if you try using SWFObject 1.x code with the SWFObject 2.x JavaScript file, your scripts will fail.
The examples (and instructions!)
- Plain vanilla SWFObject embedding.
How to use SWFObject 2.x for simple SWF embedding. - ExpressInstall example.
Using Adobe's ExpressInstall feature to automatically propmt users to upgrade outdated versions of FLash Player. - SWFObject, Flash and the z-index.
How to get your page elements to lay on top of an embedded SWF. - Returning a 'success' boolean.
How to get SWFObject to return a boolean indicating whether the dynamic embed was successful. - ExternalInterface (Flash/JavaScript communication)
How to set up your JavaScript to work with SWFObject and ExternalInterface - Scaling a SWF to 100% width and height.
The SWFObject 2.x settings and CSS code needed to expand your SWF to fill the browser. - Toggling a SWF's visibility.
The various approaches to using CSS & JavaScript to dynamically show/hide a SWF. - SWFObject 2 & Ajax.
Using SWFObject 2.x with xmlhttprequest. - Passing querystrings to a SWF using PHP.
Writing the flashvars parameter dynamically using PHP - Onclick loading.
Using an 'onclick' event and SWFObject to dynamically load a SWF - Dynamic swfobject.js links.
Using JavaScript to write the swfobject.js link dynamically