zoukankan      html  css  js  c++  java
  • FlashObject详解:Flash的检测和嵌入Javascript脚本

    原文:http://bbs.blueidea.com/thread-2536123-1-1.html

    可能很多人并不太了解FlashObject,特意把官网翻译整理了下。(E文有限,如有错误,敬请指正。)

    官方地址:http://blog.deconcept.com/flashobject/
    目前最新版本:FlashObject 1.3
    下载地址:http://blog.deconcept.com/flashobject/flashobject1-3.zip

    本文blog地址:http://blog.flashzine.cn

    特点:
    1、支持所有flash内置参数设置。且设置更简单方便。
    2、内嵌flash player升级探测器,并提示升级。
    3、完全通过XHTML 1.0 Strict验证。
    4、可以解决IE升级对flash的影响,支持绝大部分浏览器版本。

    使用方法:
    1、首先下载上面的flashobject.js文件,放到你的网页目录下。
    2、调用js文件,在<head></head>中加入:
    <script type="text/javascript" src="flashobject.js"></script>
    3、设置需要插入flash的htm代码:
    <div id="flashcontent">这里放上你想替换flash的文字。</div>
    4、在上面代码后添加flash的设置代码:
    <script type="text/javascript">
       var fo = new FlashObject("movie.swf", "mymovie", "200", "100", "7", "#336699");
       fo.write("flashcontent");
    </script>

    上面FlashObject中的基本参数设置依次为:文件地址,ID,宽度,高度,flash版本,背景色。
    可选参数有:
    useExpressInstall: 快速升级flash player 值为ture/false;
    quality:播放品质,默认为"high";
    xiRedirectUrl:指定完成(useExpressInstall)快速升级player后的定向网址。
    redirectUrl:指定flash player版本不正确的定向网址。
    detectKey:flash检测的地址参数,默认为detectflash。如:要不检测flash,可以在网址后面加上?detectflash=false。

    fo.write("flashcontent");是把flash内容写到id="flashcontent"里。

    Flash参数设置:

    一般的flash参数设置为:
    <param name="quality" value="high">
    <param name="wmode" value="transparent">

    而FlashObject的参数设置为:
    <script type="text/javascript">
       var fo = new FlashObject("movie.swf", "mymovie", "200", "100%", "7", "#336699");
       fo.addParam("quality", "low");
       fo.addParam("wmode", "transparent");
       fo.addParam("salign", "t");
       fo.write("flashcontent");
    </script>

    更多的的参数请参照Macromedia的详细介绍:http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=tn_12701

    Flashvars变量设置:

    一般的是通过Flashvars来给flash条件变量:
    <param name="FlashVars" value="variable1=value1&variable2=value2&variable3=value3">

    而FlashObject后的变量设置为:
    <script type="text/javascript">
       var fo = new FlashObject("movie.swf", "mymovie", "200", "100", "7", "#336699");
       fo.addVariable("variable1", "value1");
       fo.addVariable("variable2", "value2");
       fo.addVariable("variable3", "value3");
       fo.write("flashcontent");
    </script>
    这样设置后,所有的变量就马上传到flash的_root上了。

    另外,FlashObject还提供了一个getQueryParamValue()函数来调用URL网址串的参数。
    例如网址:http://www.example.com/page.html?variable1=value1&variable2=value2
    你可以通过以下方法来把上面的参数传递给flash。
    <script type="text/javascript">
       var fo = new FlashObject("movie.swf", "mymovie", "200", "100", "7", "#336699");
       fo.addVariable("variable1", getQueryParamValue("variable1"));
       fo.addVariable("variable2", getQueryParamValue("variable2"));
       fo.write("flashcontent");
    </script>

    同时,getQueryParamValue()还支持从location.hash读取变量。例子:
    http://www.slideshowpro.net/demo/demo_default.php


    Flash player的快速安装功能

    FlashObject完全支持Flash Player的快速安装功能。通过在flash的第一帧添加一段AS代码就可以轻松达到检测用户Flash Player版本,并提示更新的功能。expressinstall.as代码如下:

    #include "expressinstall.as"
    var ExpressInstall = new ExpressInstall();
    if (ExpressInstall.needsUpdate) {

    var upgradeMsg = attachMovie("upgradeMsg_src", "upgradeMsg", 1);
    upgradeMsg._x = Stage.width / 2;
    upgradeMsg._y = Stage.height / 2;

    upgradeMsg.upgradeBtn.onRelease = function() {
      ExpressInstall.init();
    }
    stop();
    }

    注意要把上面的AS放到主时间轴第一帧。并且这一帧上不要放任何其他内容。具体示例:
    http://blog.deconcept.com/flashobject/expressinstall.html

  • 相关阅读:
    leetcode 实现-168.Excel表列名称
    leetcode 只出现一次的数字
    leetcode 67. 二进制求和
    SQl注入测试用例
    工具使用——VMware安装及使用
    Spring基础20——AOP基础
    工具使用——IDEA常用的几种插件
    Spring基础19——Spring中几种注解的区别
    Spring基础18——通过注解配置bean之间的关联关系
    Spring基础17——使用注解来配置Bean
  • 原文地址:https://www.cnblogs.com/maqunjing/p/3073374.html
Copyright © 2011-2022 走看看