交互设计中心-72色

交互设计中心 | 用户体验 | 优化

jQuery Flash 是基于jQuery的WEB网页Flash嵌入式插件

2009年10月20日 | 分类:jquery/javascript | 评论:0 | 引用:0 | | Tags:jQuery  flash  

jQuery.Flash是基于jQuery插件的JavaScript代码,主要为了解决Flash在WEB页面的嵌入式解决方案,与AC_RunActiveContent、SWFOjbect功能类似,但是与其相比有更多的优点:
(1) 完全W3C标准
WEB页面嵌入式Flash是通过JavaScript脚本生成的,针对不同浏览器生成完全符合W3C标准的Flash页面嵌入式代码。
(2) 稳定的交互功能
在JavaScript与Flash或Flash与JavaScript交互调用的WEB页面,SWFOjbect与AC_RunActiveContent表现不够良好,由于JavaScript或Flash加载顺序问题,经常导致无法交互调用,jQuery.Flash可以完成支持JavaScript与Flash双方的互相交互。
(3) 简易而不失扩展
遵循jQuery的宗旨—Write Less,Do More,可以直接使用jQuery的元素选择器对任何一个元素进行Flash嵌入,而您仅需写一行代码,同时您可以增加任一参数进行功能扩展。
(4) 精小而不失功能
Flash插件非压缩仅3KB多一点,压缩之后不到2KB,超级精小,拥用SWFOjbect与AC_RunActiveContent的所有功能。

快速入门

下面需要实现的是将flash文件hello.swf嵌入到id为hello中div中,以下是实现步骤
1. WEB页面HTML如下:
 

<div id="hello"></div>

2. 引入JavaScript文件:

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

3. 编写调用代码实现嵌入功能:

<script type="text/javascript">
$(function(){
$('#hello').flash({src:'hello',width:550,height:400});
             })
</script>

一行代码即可实现Flash的WEB嵌入功能
上面实现的完整代码整理如下:

<div id="hello"></div>    
<script type="text/javascript" src="jquery.js"></script>    
<script type="text/javascript" src="jquery.flash.js"></script>    
<script type="text/javascript">    
$(function(){        
$('#hello').flash({src:'hello',width:550,height:400}); 
})    
</script>

使用说明

1. 首页使用jQuery选定需要嵌入的元素,这里我们使用了#hello(选定id号为hello的元素,即div);
2. 其次加入Flash文件,src即表示Flash文件,文件名为hello.swf,这里填写是不需要后缀.swf;
3. 再次定义Flash宽度width,高度400,更多的参数扩展见下面一节;

扩展参数

Flash嵌入对象的所有参数都支持

默认参数:
codebase: 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0',
quality: 'high',
pluginspage: 'http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash'

必选参数:
src:'hello',
width: 550,
height: 400,

可选参数:
id: 'demo',
name:'demo',
flashvars: {'username':'jxva','age':100},
wmode: 'transparent',
allowScriptAccess:'always',
allowFullScreen:'false'
或许还有更多参数,您只需依照上面的方式增加即可。

Share
« 更换域名后网站搬家不受损失的最佳方法翻转页面的设计 »



◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。