AS Reference  :  Notes Index  :  Resources  :  About/Contact  :  Downloads

Displaying Content Based on Flash Version Detection

With the changes in Internet Explorer requiring that a swf be clicked once to activate it, it has become necessary to use something other than the code published in the Flash IDE to detect the Flash version and display appropriate content (if one wishes to avoid making site visitors have to do that extra click). The best and easiest method for achieving this is to use SWFObject (also called FlashObject for some period of time).

SWFObject

As described on this page at adobe.com, it involves creating content within a div tag that will hold the Flash content if the correct version of Flash is detected, putting content into that div tag to display if the correct version is not detected, including swfobject.js (or flashobject.js, depending on when you got the files) in the head section of your page, and using javascript to write the Flash content into that div if the detection succeeds.

Examples

You can see an example of this by looking at the source code of the front page of this site. Note the inclusion of flashobject.js in the head section, the creation of div id="flashsection" (with an alternate image that will be displayed if the user either does not have Flash 7 or higher, or has javascript turned off), and code at the end of the html section to write Flash content if the detection (in flashobject.js) succeeds.

I also implemented a div within a table cell and used it with flashobject on this page, which I will get around to implementing on all the other pages at the site one of these days...

Flash extension for creating a template

If you want to create a ready-to-use template for use with SWFObject, instead of the traditional object/embed tags that Flash produces by default, you can download and use this JSFL command.

Testing in Firefox

Once I created and uploaded my new pages using flashobject, I tested to see if they worked in Firefox by doing the following:

I should note that there are more robust ways for switching between browser plugins to test your detection code. One I've heard often recommended is from Kewbee.

A remaining question

The one thing I have not figured out how to do using SWFObject is to show an image if the right Flash version is not detected (situation 1) and embed the swf (instead) if javascript is disabled (situation 2). It seems that one has to show the same alternate content regardless of which of those situations is encountered, so I chose the default of showing an image.

Intro
Flash: What & How
Example Sites
Create
Draw, Edit Shapes
Gradients
More Drawing Tips
Import
A Sample
Animate
Frames, Keyframes
Motion Tweens
More Motion Tweens
Shape Tweens
Masks
Control
Stop/Replay
Movieclips Intro
Movieclip Reference
Site Structure 1
Slideshow Movieclip
Contact Form
Scroll Resume
Preloader
Site Structure 2
Publish
Display Options
Player Detection
Optimize
AS 2.0 Basics
Intro to Syntax
Playhead Commands
Playhead Cmds 2
Coded Tween
onEnterFrame
Intro to Classes
Declare/Assign
Comments, Trace
Simple Data Types
Arrays & Objects
Code Blocks
Operators
Beyond Buttons
Code Structure
Toggle Controls
Group of Buttons
Drag and Hit
Distort Magnifier
Scroll Text
Bee Game
Dart Shooter
Sound Control
Easing Slider
Easing Slider 2
Components Intro
Timers & Delays
Dynamic Content
Intro
Drawing API
Create Text
Attach Movieclips
Easing Slider 3
Easing Slider 4
Load jpg/swf
Sliding Viewer
Preload swf
XML
Easing Slider 5
Server Comm
LoadVars (w/ PHP)
AS - PHP Lookup
Text File
Database 1:LoadVars
Database 2:Remoting
Read from directory
AS 2.0 Classes
Intro
Math
Key
Date
Color
EventDispatcher
New Samples
Pie Chart
Event-model Emailer
Tween Sequence
Fuse Sequence
SVG in Flash
Bitmap Topo
SWF as Data Holder
Two-level Menu
Yahoo! Flash Maps
Class-based Game
ASTB Samples
Disclaimer
3D Outlines
Bounce Collide
Address Book
Save Drawings
Home  :  Notes Index  :  Resources  :  About/Contact  :  Downloads