爱·一起乐 酷宠网络 游戏盒子·想玩就玩 发发要发·嘻嘻
SWFObject是一个用于在HTML中方面插入Adobe Flash媒体资源(*.swf文件)的独立、敏捷的JavaScript模块。该模块中的JavaScript脚本能够自动检测PC、Mac机器上各种主流浏览器对Flash插件的支持情况。它使得插入Flash媒体资源尽量简捷、安全。而且它是非常符合搜索引擎优化的原则的。此外,它能够避免您的HTML、XHTML中出现object、embed等非标准标签,从而符合更加标准。
(即:通过text/html应答页面, 而非application/xhtml+xml)

请注意: 由于法律原因,FlashObject已经更名为SWFObject,详见这里。

内容导读

新功能
实现原理
SWFObject范例
在SWFObject中应用ExpressInstall
下载
独特优势
常见问题
新功能
详细的更新记录可以在SWFObject 1.5 blog post这里找到。

实现原理
[对于急切需要下载的用户点击这里直接观看JS代码]

SWFObject的使用是非常简单的,只需要包含 swfobject.js这个js文件,然后在DOM中插入一些简单的JS代码,就能嵌入Flash媒体资源了。 下面是一个最简单的范例:

<script type="text/javascript" src="swfobject.js"></script>

<div id="flashcontent">
This text is replaced by the Flash movie.
</div>

<script type="text/javascript">
var so = new SWFObject("movie.swf", "mymovie", "200", "100", "7", "#336699");
so.write("flashcontent");
</script>让我们看看这些代码是如何工作的

<div id="flashcontent">[...]</div>首先,我们要为SWF资源预留一个HTML结点。这个HTML结点内的所有内容都会在客户端被Flash资源替换,当客户端没有安装Flash播放器的时候,这些内容会显示出来。这一特色在SEO以及对用户体验方面非常有必要。

var so = new SWFObject(swf, id, width, height, version, background-color [, quality, xiRedirectUrl, redirectUrl, detectKey]);创建一个新的SWFObject实例,并且传入一下参数:

swf - SWF文件路径
id - 您为这个SWF文件分配的id值,它将用于给embed与object标签设定name属性,以便于可以支持swliveconnect的功能,如动态传入变量
width - 宽度
height - 高度
version - FlashPlayer需要的版本号,它可以详细到 '主版本号.小版本号.细节',例如:"6.0.65"。一般地,我们只需传入主版本即可,例如:"6"。
background-color - Flash资源的背景色,16进制格式
此外,还有如下可选参数:

quality - 画面质量,默认为"high"。
xiRedirectUrl - 详见ExpressInstall相关
redirectUrl - 没有安装相应版本的播放器后自动跳转的目标地址
detectKey - 这是当忽略检测时,SWFObject将去url地址中查找的变量,默认值为“detectflash”,后续有详细介绍
so.write("flashcontent");将Flash资源应用到DOM里,在浏览器显示出来。

细节
SWFObject 的灵活性非常好。您完全可以事先写好HTML的其他部分,最后再回过头来添加Flash内容。这样可以确保在客户端没有Flash的情况下,用户不会一无所获;也可以确保针对搜索引擎,做了什么样的关键词优化。您完全不用像以前那样担心客户端的各种状况

SWFObject兼容当前各种主流浏览器,如:PC上的IE5/5.5/6, Netscape 7/8,Firefox, Mozilla, and Opera。Mac上的IE5.2, Safari, Firefox, Netscape 6/7, Mozilla, and Opera 7.5+,各种浏览器的后续版本也会继续支持

SWFObject检测Flash播放器版本从3开始到最新的版本号,而且也消灭了IE中“激活”的麻烦。这里有相关背景。

SWFObject可以方便地检查版本细节,例如我们需要v.6.0 r65 (or 6,0,65,0) 来处理SWF资源,就可以添加如下代码:

var so = new SWFObject("movie.swf", "mymovie", "200", "100", "6.0.65", "#336699");SWFObject的版本检测可以人工忽略。如果在特定环境下您不希望SWFObject检测版本号,那么只需要传递一个参数在HTML页面中,就可以了。SWFObject可以捕获这个参数并且跳过检测,直接写入Flash嵌入代码到DOM中。用于忽略版本检测的变量名是“detectflash”,以下是一个例子:

<a href="mypage.html?detectflash=false">Bypass link</a>SWFObject 范例
以上我们接触到的范例都最基础的,接下来我们列举一些其他功能,尤其是传入参数、变量这些使用频率较高的行为。

传入Flash内联参数的简单范例
<script type="text/javascript">
var so = new SWFObject("movie.swf", "mymovie", "200", "100%", "7", "#336699");
so.addParam("quality", "low");
so.addParam("wmode", "transparent");
so.addParam("salign", "t");
so.write("flashcontent");
</script>这里可以看到Flash支持的内联参数列表:full list of the current parameters and their possible values(adobe.com官方资源)

采用"Flashvars"参数传入变量
用Flashvars是在预加载Flash时传入数据的最佳做法,语法格式与GET变量串非常类似,如:variable1=value1&variable2=value2&variable3=value3SWFObject帮助您将这项工作变得更加明确化

<script type="text/javascript">
var so = new SWFObject("movie.swf", "mymovie", "200", "100", "7", "#336699");
so.addVariable("variable1", "value1");
so.addVariable("variable2", "value2");
so.addVariable("variable3", "value3");
so.write("flashcontent");
</script>这些变量将会保存在_root这个MovieClip对象里。

SWFObject还可以方便地直接从URL中接受参数传入Flash中,例如你有这样一个URL:http://www.example.com/page.html?variable1=value1&variable2=value2。采用getQueryParamValue()方法你就可以轻松获取这些参数,并将它们传入Flash,例如:


<script type="text/javascript">
var so = new SWFObject("movie.swf", "mymovie", "200", "100", "7", "#336699");
so.addVariable("variable1", getQueryParamValue("variable1"));
so.addVariable("variable2", getQueryParamValue("variable2"));
so.write("flashcontent");
</script>getQueryParamValue()方法同样可以获取JavaScript的Location对象的hash值“location.hash”来与swf内部进行通信。这里是一个采用SWFObject的应用程序,其中用到了location.hash对象:链接地址

在SWFObject中应用Express Install(利用官方自动升级接口)
SWFObject全面支持AdobeFlash播放器的自动升级功能(从6.0.65起的FlashPlayer支持在swf内部自动升级!),这样用户完全不用离开您的网页就能完成播放器的升级了。

首先,上传官方的expressinstall.swf到您的服务器上,然后使用useExpressInstall方法指定这个swf文件的地址就可以了,例如:

<script type="text/javascript">
var so = new SWFObject("movie.swf", "mymovie", "200", "100", "8", "#336699");
so.useExpressInstall('expressinstall.swf');
so.write("flashcontent");
</script>您可以安装一个低版本的Flash播放器然后访问这个页面看到效果

在SWFObject原文件压缩包中您可以找到具体的使用细节,您可以自己定制ExpressInstall的流程。

如果您的Flash影片在弹出窗口中,或者您希望用户在完成了ExpressInstall后重定向到其他地址,你可以采用xiRedirectUrl属性,来自动完成这一步骤。例如:

<script type="text/javascript">
var so = new SWFObject("movie.swf", "mymovie", "200", "100", "8", "#336699");
so.useExpressInstall('expressinstall.swf');
so.setAttribute('xiRedirectUrl', 'http://www.example.com/upgradefinished.html'); // must be the absolute URL to your site
so.write("flashcontent");
</script>下载
SWFObject基于MIT License,您可以免费任意使用。

下载 SWFObject 1.5 - Zip 文件, 包含 swfobject.js 和其他范例。

更多链接:

标准Flash嵌入 - 符合XHTML 1.0 Strict.*
全屏Flash嵌入 - 符合XHTML 1.0 Strict.*
含Express Install的标准Flash嵌入 - 从6.0.65起的FlashPlayer才支持此功能
* 页面全部是 text/html格式,不是 application/xhtml+xml.

更多问题可以访问我们的论坛:SWFObject论坛!

独特优势
多年以来,各种各样的Flash播放器版本检测代码层出不穷,包括嵌入脚本也有许多。我们在这一部分针对流行的几种方法进行一个比较。

1) Adobe官方做法
这就是经典的Object标签和Embed标签配合做法,也是目前最常用的做法:

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"
width="550" height="400" id="Untitled-1" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="mymovie.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<embed src="mymovie.swf" quality="high" bgcolor="#ffffff" width="550"
height="400" name="mymovie" align="middle" allowScriptAccess="sameDomain"
type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" />
</object>虽然是目前最常用的方法,但仍然有一些问题。

缺乏播放器版本检测 没有播放器插件版本检测,用户会获得非常糟糕的体验,他们会在不知情的情况下看到ActiveX插件安装入口,这样会导致大部分用户离开。而且,用低版本播放器播放高版本的swf文件,会导致更多潜在问题,而用户会将一切问题归咎于您的产品
Eolas专利纠纷导致IE的近期发行版中需要进行一次“激活”点击才可以完成和Flash内容的交互。详细内容
不符合XHTML规范 - 在HTML和XHTML中都没有embed标签HTML or XHTML。因为object标签在不同浏览器中的诡异表现,我们不得不用embed标签来完善最终效果。
2) 仅采用Object标签 / Flash satay
这种方法在2002年的A List Apart article出现之后开始大面积流行,这里有两个例子:

'仅含Object标签'

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"
width="300" height="120">
<param name="movie" value="http://www.macromedia.com/shockwave/download/triggerpages_mmcom/flash.swf">
<param name="quality" value="high">
<param name="bgcolor" value="#FFFFFF">
<!--[if !IE]> <-->
<object data="http://www.macromedia.com/shockwave/download/triggerpages_mmcom/flash.swf"
width="300" height="120" type="application/x-shockwave-flash">
<param name="quality" value="high">
<param name="bgcolor" value="#FFFFFF">
<param name="pluginurl" value="http://www.adobe.com/go/getflashplayer">
FAIL (the browser should render some flash content, not this).
</object>
<!--> <![endif]-->
</object>Flash satay

<object type="application/x-shockwave-flash
data="c.swf?path=movie.swf"
width="400" height="300">
<param name="movie"
value="c.swf?path=movie.swf" />
<img src="noflash.gif"
width="200" height="100" alt="" />
</object>可用性问题 - 采用 Flash Satay 的话, 一些屏幕阅读器会忽略swf内容.
Eolas专利纠纷导致IE的近期发行版中需要进行一次“激活”点击才可以完成和Flash内容的交互。详细内容
缺乏播放器版本检测 没有播放器插件版本检测,用户会获得非常糟糕的体验,他们会在不知情的情况下看到ActiveX插件安装入口,这样会导致大部分用户离开。而且,用低版本播放器播放高版本的swf文件,会导致更多潜在问题,而用户会将一切问题归咎于您的产品
早期的的Safari会忽略param标签 - 在这些版本:2.0 (Tiger) 或者 1.3 (Panther) 或者可能 1.2.8 (前Panther) 之前,Safari 完全忽略param 标签。这将会让你的Flashvars等参数无法传入。
3) 'small flash movie on the index page' 检测方法
这个方法会通过在首页放一个swf文件去访问$version 变量来返回版本信息。

问题在于:

内页无检测 - 内页如果不放着这个swf就无法检测
“激活”问题
不符合HTML或者XHTML规范
影响搜索引擎索引排名
4) Adobe官方 Flash Player Detection 模块
Adobe官方这个模块非常不错,然而仍然有一些不足,它采用两种方法来检测

Flash自身检测,如上面提到的"small Flash movie on the index page" - 缺点已经提过了
Javascript - 混乱的代码让你的HTML变得非常难以维护
深入讨论在这里。

5) 用纯粹的JS来检测、嵌入
这种方法看起来不错,但是仍然缺乏规范,而且消耗开发成本

检测不够完善 - 通常只能检测到当前的Flash播放器发行版,而且升级也需要手工参与
增加了 更多 代码 - 难以维护的DOM结构
解决方案太笨重 - SWFObject进行了多次优化,非常轻量
常见问题
这里进入论坛可以与其他用户交流

问. 到底什么是 'IE的激活内容升级' 我听说过这件事情,SWFObject能应对它么?
答. 可以,更多详细信息可以看:这里。
问. 在Flash资源加载前,相关区域的内容会有闪烁(仅IE有)
答. 这与 FOUC bug有关。
问. 用 SWFObject 嵌入多个SWF该怎么做?
答. 只要给每一个HTML结点唯一的id就可以了。
问. 如何使SWFObject兼容Netscape 4.x?
答. 这条评论包含相关信息。
问. 我如何在blog中使用SWFObject?
答. 这里有针对WordPress的插件: 这里。
问. SWFObject 是否可以与 Dreamweaver 、 Golive协同工作?
答. 这里可以得到一个Dreamweaver 扩展在CommunityMX。目前还没有GoLive扩展。
问. 哪里可以找到其他语言的翻译?
答. 法语 ,瑞典语, 意大利语, 德语, 西班牙语, 波兰语(部分), 日语, 葡萄牙语,和 芬兰语。
问. 有支持FlashIDE的发布插件么?
答. 有!你可以在这里得到: Fluid Flash Blog。
问. 谁在使用SWFObject/FlashObject?
答. 这些网站: The Library of Congress, Adobe.com (制定的轻量版本), Amazon.com, Windows.com, YouTube.com, skype.com, Snapple.com, 包括 Adobe Photoshop (在Flash画廊中的) 和大量其他的网站. Colin Moock 也 推荐这种解决方案。
仍然有疑问? 这里有我之前的一些文章[1, 2, 3] 这些日志,以及评论含有许多丰富的解决思路。

致谢
Toby Boudreaux给了我大量的建议,让我的代码更加快捷可靠。
  • 葫芦娃娃
    • SWFObject:Javascript Flash Player detection and embed script
      • 酷鱼设计 @ 2007.08.04 10:41
      • 1楼
SWFObject is a small Javascript file used for embedding Adobe Flash content. The script can detect the Flash plug-in in all major web browsers (on Mac and PC) and is designed to make embedding Flash movies as easy as possible. It is also very search engine friendly, degrades gracefully, can be used in valid HTML and XHTML 1.0 documents*, and is forward compatible, so it should work for years to come.
* Pages sent as text/html, not application/xhtml+xml.

Please note: SWFObject is the SWF embed script formerly known as FlashObject. The name was changed due to legal / trademark reasons. For more information, see this post.

Table of Contents

What's new in this version?
How it works
SWFObject Examples
Using ExpressInstall with SWFObject
Download
Why it's better than the rest
FAQ
What's new in this version?
For a full list of changes, please see my SWFObject 1.5 blog post.

How it works
[For the über nerds, you can view the raw javascript here.]

Using SWFObject is easy. Simply include the swfobject.js Javascript file, then use a small amount of Javascript on your page to embed your Flash movie. Here is an example showing the minimum amount of code needed to embed a Flash movie:

<script type="text/javascript" src="swfobject.js"></script>

<div id="flashcontent">
This text is replaced by the Flash movie.
</div>

<script type="text/javascript">
var so = new SWFObject("movie.swf", "mymovie", "400", "200", "8", "#336699");
so.write("flashcontent");
</script>Here is a breakdown of what the code does:

<div id="flashcontent">[...]</div>Prepare an HTML element that will hold our Flash movie. The content placed in the 'holder' element will be replaced by the Flash content, so users with the Flash plug-in installed will never see the content inside this element. This feature has the added bonus of letting search engines index your alternate content.

var so = new SWFObject(swf, id, width, height, version, background-color [, quality, xiRedirectUrl, redirectUrl, detectKey]);Create a new SWFObject and pass in the required arguments:

swf - The file path and name to your swf file.
id - The ID of your object or embed tag. The embed tag will also have this value set as it's name attribute for files that take advantage of swliveconnect.
width - The width of your Flash movie.
height - The height of your Flash movie.
version - The required player version for your Flash content. This can be a string in the format of 'majorVersion.minorVersion.revision'. An example would be: "6.0.65". Or you can just require the major version, such as "6".
background-color - This is the hex value of the background color of your Flash movie.
Optional arguments are:

quality - The quality you wish your Flash movie to play at. If no quality is specified, the default is "high".
xiRedirectUrl - If you would like to redirect users who complete the ExpressInstall upgrade, you can specify an alternate URL here
redirectUrl - If you wish to redirect users who don't have the correct plug-in version, use this parameter and they will be redirected.
detectKey - This is the url variable name the SWFObject script will look for when bypassing the detection. Default is 'detectflash'. Example: To bypass the Flash detection and simply write the Flash movie to the page, you could add ?detectflash=false to the url of the document containing the Flash movie.
so.write("flashcontent");Tell the SWFObject script to write the Flash content to the page (if the correct version of the plug-in is installed on the user's system) by replacing the content inside the specified HTML element.

The Details
SWFObject works quietly in the background of your HTML document. When developing pages that use SWFObject, you should start with your alternate (non-Flash) content first. Get your pages working without your Flash movies, then add them in later with little Javascript snippets that replace your alternate content with the Flash movies. This ensures that the alternate content will be indexed by search engines, and that users without the Flash plug-in will still see a working HTML page. Whether you provide upgrade instructions or not is up to you. If your alternate content can suffice, there may be no reason at all to tell people they are missing out on Flash content.

SWFObject works in all the current web browsers, including, on PC: IE5/5.5/6, Netscape 7/8, Firefox, Mozilla, and Opera. On Mac: IE5.2, Safari, Firefox, Netscape 6/7, Mozilla, and Opera 7.5+, and should continue to work well into the future.

SWFObject detects Flash player versions in these browsers from version 3 and up, and will allow users to interact with your Flash content without 'activating' it first. For more information on this, see this blog post on the Internet Explorer Eolas patent dispute.

SWFObject can detect minor versions and revision versions of the Flash Player as well, simply by passing the string value of the version you want. An example of requiring Flash player v.6.0 r65 (or 6,0,65,0) would be:

var so = new SWFObject("movie.swf", "mymovie", "200", "100", "6.0.65", "#336699");SWFObject's built in plug-in detection can be bypassed. If a new browser is ever launched or for some reason the plug-in detection fails on a user's system, you can include a bypass link that will disable the detection built into SWFObject, and it will always write the Flash content to the page. To use the bypass link, simply link to the page with your Flash content on it, and include a single url variable called 'detectflash' and set it to 'false.' Here is an example of what that link would look like:

<a href="mypage.html?detectflash=false">Bypass link</a>SWFObject Examples
The example given above is what you need for the bare bones use of SWFObject, but what if you want to use some of the other parameters the Flash plug-in has to offer? SWFObject makes it very easy to add any extra parameter you may need. The examples below are a number of different methods you may wish to use to embed your Flash content.

A simple example adding a few extra parameters
<script type="text/javascript">
var so = new SWFObject("movie.swf", "mymovie", "400", "100%", "8", "#336699");
so.addParam("quality", "low");
so.addParam("wmode", "transparent");
so.addParam("salign", "t");
so.write("flashcontent");
</script>Here is a full list of the current parameters and their possible values on adobe.com.

Passing variables into your movies using the "Flashvars" parameter:
Using Flashvars is the easiest way to get data from your HTML into your Flash movie, but you can only pass the data in when your movie first loads. Normally, you would add a parameter called "flashvars" and then for the value, you passing a string of name/value pairs like this: variable1=value1&variable2=value2&variable3=value3 and so on. SWFObject makes this a bit easier by allowing you to add as many variables as you like in a similar manner in which you add additional parameters. Here is an example of passing values into your Flash movie using Flashvars:

<script type="text/javascript">
var so = new SWFObject("movie.swf", "mymovie", "400", "200", "8", "#336699");
so.addVariable("variable1", "value1");
so.addVariable("variable2", "value2");
so.addVariable("variable3", "value3");
so.write("flashcontent");
</script>Once this is done, all of the variables you pass in will be available immediately inside the Flash movie. Just access them as you would any variable on the _root timeline.

The SWFObject script also comes with an extra function which allows you to pull variable values from the url string. An example is you have a url that looks like this: http://www.example.com/page.html?variable1=value1&variable2=value2. Using the function getQueryParamValue() you can easily pull these values from the url and then pass them into your Flash movie. Here is an example, we'll assume that the url looks like the above example:

<script type="text/javascript">
var so = new SWFObject("movie.swf", "mymovie", "400", "200", "8", "#336699");
so.addVariable("variable1", getQueryParamValue("variable1"));
so.addVariable("variable2", getQueryParamValue("variable2"));
so.write("flashcontent");
</script>The getQueryParamValue() function also supports reading variables from the location.hash, as used sometimes when deep linking into your Flash applications. For an example of how deep linking to your Flash movies using the location.hash variable, check out this demo of Slideshow Pro, which uses the SWFObject embed.

Using Express Install with SWFObject
SWFObject has full support for the Adobe Flash Player Express Install feature. Your users never have to leave your site to upgrade their player.

To use ExpressInstall, you must first upload the expressinstall.swf to your web server. Then, use the useExpressInstall method to specify the path to your expressinstall.swf. If no path is specified, SWFObject will look in the same folder as the current HTML page.

<script type="text/javascript">
var so = new SWFObject("movie.swf", "mymovie", "200", "100", "8", "#336699");
so.useExpressInstall('expressinstall.swf');
so.write("flashcontent");
</script>If you want to see ExpressInstall in action, you can install Flash player 7 (or 6.0.65) and visit this page.

If you wish to customize the Express Install feature, the source code to the expressinstall.swf is included with SWFObject.

If your Flash movie is in a popup window, or you wish to redirect the user to a different location after they complete the ExpressInstall update, you can use the xiRedirectUrl attribute to redirect the user back to your landing page instead of the actual page with your Flash movie.

<script type="text/javascript">
var so = new SWFObject("movie.swf", "mymovie", "200", "100", "8", "#336699");
so.useExpressInstall('expressinstall.swf');
so.setAttribute('xiRedirectUrl', 'http://www.example.com/upgradefinished.html'); // must be the absolute URL to your site
so.write("flashcontent");
</script>Download
SWFObject is released under the MIT License. This means (basically) that you can use it for whatever you want with no restrictions.

Download SWFObject 1.5 - Zip file, includes swfobject.js and the example html templates below.

Or, if you are more of a hands on type, you can view my example pages:

Standard Flash embed - No bells and whistles, just a straigt forward Flash movie on a page with a variable passed in. Valid XHTML 1.0 Strict.*
100% width and height Flash embed - Having trouble getting your Flash movie to fill the screen? Try this template. Valid XHTML 1.0 Strict.*
Standard Flash embed with Express Install enabled - This page will attempt to upgrade your Flash player if you have a version lower than 8 (requires version 6.0.65 or higher)
* Pages are sent as text/html, not application/xhtml+xml.

Need help with SWFObject? Try asking for help in the SWFObject forum!

Why it's is better than the rest
Over the years there have been many methods to detect Flash player versions and embed Flash movies into HTML documents. This section will take a look at each of the most popular methods and point out the problems with each.

1) The default Adobe provided embed
Everyone knows the default Adobe provided Flash embed. It consists of an Object tag with an Embed tag placed inside as a fallback mechanism. This is the most popular Flash embed method and is the default choice when publishing your Flash movie from the Adobe Flash IDE. This is the most compatible way to embed a Flash movie, and will work in the widest range of browsers. Here is a sample of the default Flash embed code:

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"
width="550" height="400" id="Untitled-1" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="mymovie.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<embed src="mymovie.swf" quality="high" bgcolor="#ffffff" width="550"
height="400" name="mymovie" align="middle" allowScriptAccess="sameDomain"
type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" />
</object>While this is the most common method of embedding your Flash movies, it does have a few issues.

There is noplug-in detection. - With no plug-in detection, users may see broken or no content, and if there is no plug-in installed at all, they will either get the 'ActiveX install' dialog box on IE —a box many users now fear because of rampant spyware and malware— or the 'strange puzzle piece' box in Mozilla based browsers. Neither of these plug-in install systems are very user friendly, and usually don't explain themselves very well as to what exactly a user is installing.
With changes from the Eolas patent dispute, users will have to first click on your Flash content to 'activate' it before interacting with it. More info here.
It is not valid HTML or XHTML - There is no such thing as an embed tag in any version of HTML or XHTML. However, since many browsers handle object tags differently (or not at all, or the implementation is too buggy), the embed tag was needed as a fallback mechanism.
2) Object tag only / Flash satay
This method gained popularity after the A List Apart article came out back in 2002. Here are two examples of 'object tag only' embedding and Flash satay:

'Object tag only'

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"
width="300" height="120">
<param name="movie" value="http://www.macromedia.com/shockwave/download/triggerpages_mmcom/flash.swf">
<param name="quality" value="high">
<param name="bgcolor" value="#FFFFFF">
<!--[if !IE]> <-->
<object data="http://www.macromedia.com/shockwave/download/triggerpages_mmcom/flash.swf"
width="300" height="120" type="application/x-shockwave-flash">
<param name="quality" value="high">
<param name="bgcolor" value="#FFFFFF">
<param name="pluginurl" value="http://www.adobe.com/go/getflashplayer">
FAIL (the browser should render some flash content, not this).
</object>
<!--> <![endif]-->
</object>Flash satay

<object type="application/x-shockwave-flash
data="c.swf?path=movie.swf"
width="400" height="300">
<param name="movie"
value="c.swf?path=movie.swf" />
<img src="noflash.gif"
width="200" height="100" alt="" />
</object>Accessibility issues. - Using Flash Satay, some screen readers (like JAWS) will ignore your Flash content.
With changes from the Eolas patent dispute, users will have to first click on your Flash content to 'activate' it before interacting with it. More info here.
There is noplug-in detection. - Same as above - With no plug-in detection, users may see broken or no content. When the Flash player encounters a Flash movie embedded in a page, it will try to play it no matter what the version is. So if you have Flash player 6 installed, and encounter a Flash 7 movie, your plug-in will try to play it, possibly causing odd behavior.
Some methods of Flash satay don't stream the Flash movie to the player - So this method may require 'holder' swf movies that your movie is loaded in to. This makes passing variables from FlashVars parameters a hassle and make it a pain to maintain Flash content as you now have twice as many swf files floating around your web server.
Older Safari versions ignore param tags - Up until version 2.0 (on Tiger) or 1.3 (on Panther) and possibly 1.2.8 (pre Panther) Safari would completely ignore the param tag. This meant that if you tried to set other options using them, like Flashvars or Align, Salign, etc. Safari would not see those values.
3) Detection: The 'small flash movie on the index page' method
This method involves placing a single Flash movie on the index page of your website, and this Flash movie then checks the $version variable in the Flash player and redirects the user either to the Flash content inside the site, or an upgrade page.

Problems with this method include:

There is noplug-in detection on internal pages. - If a user sends an internal url to another user, that new user bypasses the Flash detection on the index page.
With changes from the Eolas patent dispute, users will have to first click on your Flash content to 'activate' it before interacting with it. More info here.
It is not valid HTML or XHTML - Again, the embed tag required to place the Flash movies in your HTML documents will not validate.
Hurts your search engine ranking - Since you are now using your index page as an empty Flash detection page, when people search for you in Google or other search engines, often the description text ends up showing up as "Detecting Flash Player" or even no description at all. This is a huge waste of prime website real estate that should be used to promote your company or products. Often times developers will not include a link to the other content in the site (since the Flash movie contains the links) so the rest of the site won't be indexed either.
4) The Adobe Flash Player Detection Kit
Adobe has done an excellent job with the new Flash 8 detection kit - but not quite excellent enough. It contains two different ways to detect the Flash plug-in:

The classic "small Flash movie on the index page" - (See above)
Javascript - Yes, that's right, Flash now includes a Javascript plug-in detection template. Unfortunately, it's very not very user friendly at all, mixing Javascript, VBscript, and all your HTML all into one page. This has many of the drawbacks as past Javascript detection and embed techniques, and doesn't do anything to make your life easier as a Flash/HTML developer. And it doesn't validate as XHTML or HTML (If you care about that sort of thing).
I've put together a more in-depth look at the Adobe detection kit over here.

5) Use raw Javascript to detect and embed your movies
It's hard to critique this method as it usually varies from site to site. However, most Javascript Flash detection schemes I have come across generally suffer from the same faults:

Unreliable plug-in Detection - Often the detection only works with current versions of the Flash player, and needs to be manually updated as new versions of the plug-in are released.
Adds more code to the page - Making it even harder to update or change your content. This method also makes it harder for designers or other people that may be working with your pages to change or add Flash movies.
An overly complicated solution - Many Flash embedding scripts can grow to large file sizes or be overly complicated. SWFObject is designed to be simple and small.
FAQ
SWFObject now has a forum for people looking for help implementing it. Please send all support requests to the forum, there are plenty of capable people there to help you.

Q. What is this Internet Explorer 'Active Content Update' I've been hearing about, and does SWFObject fix it?
A. The short answer is yes, SWFObject will fix the 'Activating Active Content' issues in the new IE Update. You read more about the subject here.
Q. Why does my alternate content flicker quickly on the screen before my Flash content loads? (only happens in IE on Windows)
A. This seems to be related to the FOUC bug. It can be fixed by adding a link tag in the head of your document to any stylesheet.
Q. Can I use SWFObject to embed more than one SWF on an HTML page?
A. Yes. Just give each SWF and each div or HTML element that will hold a SWF a unique Id.
Q. How can I make SWFObject work in Netscape 4.x?
A. This comment has some example code that you can use to make SWFObject work in Netscape 4.x.
Q. Can I use SWFObject with my Blog?
A. Yes, there are a couple of plug-ins for Wordpress and Textpattern here.
Q. Can I use SWFObject with Dreamweaver or Golive?
A. There is a Dreamweaver extension available at CommunityMX. There is currently no Golive extension, but if you would like to make one, I'll gladly link it up from this page. You should be able to use the SWFObject script without an extension, but the extension should make it much easier.
Q. Is this page available in other languages?
A. Here is a French translation of parts of this page, a Swedish translation, Italian, German, Spanish, Polish (partial), Japanese, Portuguese (Brazilian), Chinese, and here is a Finnish translation. If anyone would like to translate this page into other languages, I would be happy to post a link here.
Q. Is there a publishing template I can use with Flash?
A. Yes. You can download one from the Fluid Flash Blog.
Q. Who uses SWFObject/FlashObject?
A. Websites like The Library of Congress, Adobe.com (A slightly customized version), Amazon.com, Windows.com, YouTube.com, skype.com, Snapple.com, it is included with Adobe Photoshop (in the Flash web photo galleries) and thousands of others. Colin Moock also suggests it as an alternative to the Adobe Detection kit.
Still having problems? Try reading through the previous SWFObject posts [1, 2, 3] on this blog (especially the comments), as many common questions have been covered there.

Thanks
Toby Boudreaux gave me tons of advice, helped make the code for SWFObject much cleaner and name spaced it all at the same time.