的SWFObject最实用的功能
评论:我一直想写一个js库swfobject推荐,因为它是便携式的,强大的,这给我们的发展带来了很大的方便。SWFObject是闪存版本检测和基于Javascript模块嵌入。其主要目的是使我们能够将Flash嵌入到网页中,操作更简单,增加版本检测功能,符合XHTML标准测试。
我一直想写一种SWFObject JS类库的推荐,因为他是轻量级的,强大的和极大的方便了我们的发展。
SWFObject是基于Javascript的闪存版本检测和嵌入模块,其主要目的是利用嵌入网页的Flash操作更简单,加入了版本检测功能,随着XHTML标准插入验证,和IE上点击激活限制Flash版本,可兼容主流浏览器。
让我们先看一段SWFObject的代码:
/ /负载SWFObject图书馆
设置一个div,并设置id,div将用于插入Flash容器。
播放这个动画需要flashplayre8.0
使用SWFObject插入闪存 / /
无功所以=新SWFObject(电影。SWF
对Flash内容 / div替换Flash标识内容
so.write(Flash内容);
看看上面的代码感觉怎么样相比于通常的对象插入Flash文件是不是更简洁,和代码结构清晰,此代码解释中国看到AW SWFObject的翻译,已经很详细了,不再多说,这里只介绍个人认为最实用的功能。
1。版本检测
There are users of the player version is too low, and most of them are low-end users, the computer knowledge is shallow, if they do not see that we have the FLASH animation, or because of some characteristics of the new version is not supported by the player version, users see the incomplete animation, then this is a bad user it is easy for users to experience, all factors are attributed to the product developer.The utility SWFObject can well avoid the trouble when it detects a user's player version is lower than we set the version, FLASH DIV does not replace the contents of the container, so we can suggest to the user here for example: ldquo; you need to upgrade to the 8 version of FLASH player;.If conditions permit, we can give useRS更新Adobe的Flash播放器的链接,或者提供一个活跃的安装包直接给用户下载并安装。
两。支持FlashVars
so.addvariable(arg1
so.addvariable(2
上述代码将闪光的根在FlashVars的方式添加两个变量,arg1,arg2 test1,test2 =,是简洁和方便。同时,我们不需要考虑IE和FF之间的兼容性。
注意:js和Flash之间的通信是通过字符串传递的,所以数字类型变量的flash结尾需要进行类型转换。
三。设置flash内联参数
So.addParam(窗口模式
这是我们在设置Flash背景透明代码时所熟悉的,可以尝试设置其他内嵌属性。
四,在URL中获取变量
对于urlarg1 = test1arg2 = test2,URL,通过变量的获取方式,我们可以使用getqueryparamvalue方法得到的变量。
VaR T1 = getqueryparamvalue(arg1 );
警报(t1);