SWFObject 2.0的使用说明
<div id="myContent">
<p>Alternative content</p>
</div>
swfobject.embedSWF(swfUrl, id, width, height, version, expressInstallSwfurl, flashvars, params, attributes)有5个必须的参数和4个可选的参数:
swfUrl(String,必须的)指定SWF的URL。
id(String,必须的)指定将会被Flash内容替换的HTML元素(包含你的替换内容)的id。
width(String,必须的)指定SWF的宽。
height(String,必须的)指定SWF的高。
version(String,必须的)指定你发布的SWF对应的Flash Player版本(格式为:major.minor.release)。
expressInstallSwfurl(String,可选的)指定express install SWF的URL并激活Adobe express install [ http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=6a253b75 ]。
flashvars(String,可选的)用name:value对指定你的flashvars。
params(String,可选的)用name:value对指定你的嵌套object元素的params。
attributes(String,可选的)用name:value对指定object的属性。
注意:在不破坏参数顺序的情况下,你可以忽略可选参数。如果你不想使用一个可选参数,但是会使用后面的一个可选参数,你可以简单的传入false作为参数的值。对flashvars、 params和 attributes这些JavaScript对象来说,你也可以相应的传入一个空对象{}。
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
swfobject.embedSWF("myContent.swf", "myContent", "300", "120", "9.0.0");
</script>
-------------------------------------------------------------------------
你可以为你的object元素添加下面这些常用的可选属性(attributes)[ http://www.w3schools.com/tags/tag_object.asp ]:
id
name
styleclass(不使用class,因为class也是ECMA4的保留关键字)s
align
你可以使用下面这些专用于Flash的可选param元素[ http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_12701 ]:
play
loop
menu
quality
scale
salign
wmode
bgcolor
base
swliveconnect
flashvars
devicefont [ http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_13331 ]
allowscriptaccess [ http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_16494 ]
seamlesstabbing [ http://www.adobe.com/support/documentation/en/flashplayer/7/releasenotes.html ]
allowfullscreen [ http://www.adobe.com/devnet/flashplayer/articles/full_screen_mode.html ]
allownetworking [ http://livedocs.adobe.com/flash/9.0/main/00001079.html ]
-------------------------------------------------------------------------------------------------------------
<script type="text/javascript">
var flashvars = {};
var params = {};
var attributes = {};
swfobject.embedSWF("myContent.swf", "myContent", "300", "120", "9.0.0","expressInstall.swf", flashvars, params, attributes);
</script>
---------------------------------------------------------------------------------------------------------------------------
<script type="text/javascript">
var flashvars = {};
flashvars.name1 = "hello";
flashvars.name2 = "world";
flashvars.name3 = "foobar";
var params = {};
params.menu = "false";
var attributes = {};
attributes.id = "myDynamicContent";
attributes.name = "myDynamicContent";
swfobject.embedSWF("myContent.swf", "myContent", "300", "120", "9.0.0","expressInstall.swf", flashvars, params, attributes);
</script>
-------------------------------------------------------------------
<script type="text/javascript">
swfobject.embedSWF("myContent.swf", "myContent", "300", "120", "9.0.0","expressInstall.swf", {name1:"hello",name2:"world",name3:"foobar"}, {menu:"false"}, {id:"myDynamicContent",name:"myDynamicContent"});
</script>
--------------------------------------------------------------------
<script type="text/javascript">
var flashvars = false;
var params = {};
var attributes = {
id: "myDynamicContent",
name: "myDynamicContent"
};
swfobject.embedSWF("myContent.swf", "myContent", "300", "120", "9.0.0","expressInstall.swf", flashvars, params, attributes);
</script>
-------------------------------------------------------
<script type="text/javascript">
var flashvars = false;
var params = {
menu: "false",
flashvars: "name1=hello&name2=world&name3=foobar"
};
var attributes = {
id: "myDynamicContent",
name: "myDynamicContent"
};
swfobject.embedSWF("myContent.swf", "myContent", "300", "120", "9.0.0","expressInstall.swf", flashvars, params, attributes);
</script>
================================================
从SWFObject 1.5迁移到SWFObject 2.0的注意事项
SWFObject 2.0并不向后兼容SWFObject 1.5。
现在更倾向于在HTML页面的head标签中插入所有的脚本文件。
现在类库使用的是小写:swfobject,而不是SWFObject。
现在只能通过类库(的类)来访问方法(译者注:即静态方法),而不是像从SWFObject v1.5中那样通过SWFObject的实例来访问。
API跟以前完全不同了,而且更详尽:[ http://code.google.com/p/swfobject/wiki/SWFObject_2_0_api_javascript_dev ]。
如果浏览器对JavaScript和Flash有足够的支持,SWFObject 2.0会将整个替换内容,包括被引用的HTML容器元素,替换为Flash内容,而不是像SWFObject 1.5那样,只把被引用容器里面的内容替换为Flash内容。你现在可以这样转移你的CSS规则:为你的Flash内容定义与替换内容的容器元素相同的 id(前者将替换后者,所以你的id不会重复)。
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/liguohuaty/archive/2009/08/18/4460443.aspx