SWFObject推出2.0版本了[转]

2008-07-20 22:46:38

SWFObject推出2.0版本了,并在code.google.com上建立了开源项目[http://code.google.com/p/swfobject/]。 SWFObject是简单易用的Flash嵌入和检测JS代码,个人觉得比Adobe官方提供要更为方便,也更为易用的。这次版本更新改动非常大。 SWFObject2.0现提供两个主要调用方法。 1.swfobject.registerObject(flashContentId, flashVersion,expressInstallUrl ); flashContentId为Flash的ID; flashVersion为播放SWF的Player版本; expressInstallUrl为Flash Player更新安装的swf调用地址;如果当前版本低于flashVersion将自动更新。[html]<!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Strict//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&#34;> <html xmlns=&#34;http://www.w3.org/1999/xhtml&#34; lang=&#34;en&#34; xml:lang=&#34;en&#34;> <head> <title>SWFObject v2.0 sample page</title> <meta http-equiv=&#34;Content-Type&#34; content=&#34;text/html; charset=iso-8859-1&#34; /> <script type=&#34;text/javascript&#34; src=&#34;swfobject.js&#34;></script> <script type=&#34;text/javascript&#34;> swfobject.registerObject(&#34;myId&#34;, &#34;9.0.0&#34;, &#34;expressInstall.swf&#34;); </script> </head> <body> <div> <object id=&#34;myId&#34; classid=&#34;clsid:D27CDB6E-AE6D-11cf-96B8-444553540000&#34; width=&#34;300&#34; height=&#34;120&#34;> <param name=&#34;movie&#34; value=&#34;test.swf&#34; /> <!--[if !IE]>--> <object type=&#34;application/x-shockwave-flash&#34; data=&#34;test.swf&#34; width=&#34;300&#34; height=&#34;120&#34;> <!--<![endif]--> <div> <h1>Alt&#101;rnative content</h1> <p><a href=&#34;http://www.adobe.com/go/getflashplayer&#34;><img src=&#34;http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif&#34; alt=&#34;Get Adobe Flash player&#34; /></a></p> </div> <!--[if !IE]>--> </object> <!--<![endif]--> </object> </div> </body> </html> [/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=&#34;false&#34; ; attributes为flash player控件的属性值设置;如class=&#34;flashstyle&#34;;[html]<!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Strict//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&#34;> <html xmlns=&#34;http://www.w3.org/1999/xhtml&#34; lang=&#34;en&#34; xml:lang=&#34;en&#34;> <head> <title>demo</title> <meta http-equiv=&#34;Content-Type&#34; content=&#34;text/html; charset=utf-8&#34; /> <script type=&#34;text/javascript&#34; src=&#34;swfobject.js&#34;></script> <script type=&#34;text/javascript&#34;> var flashvars = {}; flashvars.sn = &#34;a00001&#34;; var params = {}; params.menu = &#34;false&#34;; params.quality = &#34;autohigh&#34;; params.wmode = &#34;opaque&#34;; params.allowfullscreen = &#34;true&#34;; params.allowscriptaccess = &#34;always&#34;; params.allownetworking = &#34;all&#34;; var attributes = {}; swfobject.embedSWF(&#34;test.swf&#34;, &#34;flashcontent&#34;, &#34;300&#34;, &#34;120&#34;, &#34;9.0.0&#34;, &#34;expressInstall.swf&#34;, flashvars, params, attributes); </script> </head> <body> <div id=&#34;flashcontent&#34;> <a href=&#34;http://www.adobe.com/go/getflashplayer&#34;> <img src=&#34;http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif&#34; alt=&#34;Get Adobe Flash player&#34; border=&#34;0&#34; /> </a> </div> </body> </html> [/html] SWFObject下载包:[url=http://swfobject.googlecode.com/files/swfobject_2_0.zip ]http://swfobject.googlecode.com/files/swfobject_2_0.zip [/url] SWFObject的html生成器:[url=http://swfobject.googlecode.com/files/swfobject_2_0_generator_1_1_html.zip]http://swfobject.googlecode.com/files/swfobject_2_0_generator_1_1_html.zip[/url] SWFObject的官方Blog:[url=http://blog.deconcept.com/swfobject/ ]http://blog.deconcept.com/swfobject/ [/url]