SWFObject推出2.0版本了,并在code.google.com上建立了开源项目[]。
SWFObject是简单易用的Flash嵌入和检测JS代码,个人觉得比Adobe官方提供要更为方便,也更为易用的。这次版本更新改动非常大。
SWFObject2.0现提供两个主要调用方法。
1.swfobject.registerObject(flashContentId, flashVersion,expressInstallUrl );
flashContentId为Flash的ID;
flashVersion为播放SWF的Player版本;
expressInstallUrl为Flash Player更新安装的swf调用地址;如果当前版本低于flashVersion将自动更新。
- >
- <html xmlns="" lang="en" xml:lang="en">
- <head>
- <title>SWFObject v2.0 sample pagetitle>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
- <script type="text/javascript" src="swfobject.js">script>
- <script type="text/javascript">
- swfobject.registerObject("myId", "9.0.0", "expressInstall.swf");
- script>
- head>
- <body>
- <div>
- <object id="myId" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="300" height="120">
- <param name="movie" value="test.swf" />
-
- <object type="application/x-shockwave-flash" data="test.swf" width="300" height="120">
-
- <div>
- <h1>Alternative contenth1>
- <p><a href=""><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />a>p>
- div>
-
- object>
-
- object>
- div>
- body>
- html>
2.swfobject.embedSWF(swfUrl, replaceElementId, swfWidth, swfHeight, flashVersion,expressInstallUrl, flashvars, params, attributes);
swfUrl为调用swf的地址;
replaceElementId为要用于替换成flash的可显示容器的ID;
swfWidth为swf的宽度;
swfHeight为swf的高度;
flashVersion为播放SWF的Player版本;
expressInstallUrl为Flash Player更新安装的swf调用地址;如果当前版本低于flashVersion将自动更新。
flashvars为flashvars传递的变量值;
params为flash player控件的参数设置;如menu="false" ;
attributes为flash player控件的属性值设置;如class="flashstyle";
- >
- <html xmlns="" lang="en" xml:lang="en">
- <head>
- <title>demotitle>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <script type="text/javascript" src="swfobject.js">script>
- <script type="text/javascript">
- var flashvars = {};
- flashvars.sn = "a00001";
- var params = {};
- params.menu = "false";
- params.quality = "autohigh";
- params.wmode = "opaque";
- params.allowfullscreen = "true";
- params.allowscriptaccess = "always";
- params.allownetworking = "all";
- var attributes = {};
- swfobject.embedSWF("test.swf", "flashcontent", "300", "120", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
- script>
- head>
- <body>
- <div id="flashcontent">
- <a href="">
- <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" border="0" />
- a>
- div>
- body>
- html>
SWFObject下载包:
SWFObject的html生成器:
SWFObject的官方Blog:
http://blog.deconcept.com/swfobject/
阅读(355) | 评论(0) | 转发(0) |