Flash:同一页面上有许多相同的 SWF

2023-12-31

Summary

我正在尝试制作一个包含多个相同 SWF 的网页。我遇到的问题是加载速度太慢(不过下载时间还不错)。我的每个单元格中有一个 4x4 表格,iframe 中嵌入了一个 swf 文件。(注:4 X 4 表 => 16 SWFS).

我的 AS3 代码非常简单:

package
{
    import flash.display.Sprite;
    import flash.system.System;
    import flash.text.TextField;

    public class ActionscriptProject extends Sprite
    {
        public function ActionscriptProject()
        {
            var txt:TextField = new TextField();
            txt.x=0;
            txt.y=0;
            txt.width=5000;
            txt.height=5000;
            addChild(txt);
            txt.htmlText+="<font size='45'>"+System.totalMemory/1048576 + " MB"+"</font>";
        }
    }
}

我使用以下 html 将其加载到 iframe 中:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Flash Testing</title>
</head>
<body>

<table border="1">
    <tr>
        <td>
            <iframe allowtransparency='true' scrolling='no' src='Flash/ActionscriptProject.html'></iframe>
        </td>
        <td>
            <iframe allowtransparency='true' scrolling='no' src='Flash/ActionscriptProject.html'></iframe>
        </td>
        <td>
            <iframe allowtransparency='true' scrolling='no' src='Flash/ActionscriptProject.html'></iframe>
        </td>
        <td>
            <iframe allowtransparency='true' scrolling='no' src='Flash/ActionscriptProject.html'></iframe>
        </td>
    </tr>
    <tr>
        ...
    </tr>
    <tr>
        ...
    </tr>
    <tr>
        ...
    </tr>
</table>    

</body>
</html>

注意:ActionscriptProject.html 只是 Flash Builder 使用应用程序创建的标准 html。但应 The_asMan 的要求,我将其包含在这里:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- saved from url=(0014)about:internet -->
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> 
    <!-- 
    Smart developers always View Source. 

    This application was built using Adobe Flex, an open source framework
    for building rich Internet applications that get delivered via the
    Flash Player or to desktops via Adobe AIR. 

    Learn more about Flex at http://flex.org 
    // -->
    <head>
        <title></title>         
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <!-- Include CSS to eliminate any default margins/padding and set the height of the html element and 
             the body element to 100%, because Firefox, or any Gecko based browser, interprets percentage as 
             the percentage of the height of its parent container, which has to be set explicitly.  Initially, 
             don't display flashContent div so it won't show if JavaScript disabled.
        -->
        <style type="text/css" media="screen"> 
            html, body  { height:100%; }
            body { margin:0; padding:0; overflow:auto; text-align:center; 
                   background-color: #ffffff; }   
            #flashContent { display:none; }
        </style>

        <!-- Enable Browser History by replacing useBrowserHistory tokens with two hyphens -->
        <!-- BEGIN Browser History required section -->
        <link rel="stylesheet" type="text/css" href="history/history.css" />
        <script type="text/javascript" src="history/history.js"></script>
        <!-- END Browser History required section -->  

        <script type="text/javascript" src="swfobject.js"></script>
        <script type="text/javascript">
            <!-- For version detection, set to min. required Flash Player version, or 0 (or 0.0.0), for no version detection. --> 
            var swfVersionStr = "10.0.0";
            <!-- To use express install, set to playerProductInstall.swf, otherwise the empty string. -->
            var xiSwfUrlStr = "playerProductInstall.swf";
            var flashvars = {};
            var params = {};
            params.quality = "high";
            params.bgcolor = "#ffffff";
            params.allowscriptaccess = "sameDomain";
            params.allowfullscreen = "true";
            var attributes = {};
            attributes.id = "ActionscriptProject";
            attributes.name = "ActionscriptProject";
            attributes.align = "middle";
            swfobject.embedSWF(
                "ActionscriptProject.swf", "flashContent", 
                "100%", "100%", 
                swfVersionStr, xiSwfUrlStr, 
                flashvars, params, attributes);
            <!-- JavaScript enabled so display the flashContent div in case it is not replaced with a swf object. -->
            swfobject.createCSS("#flashContent", "display:block;text-align:left;");
        </script>
    </head>
    <body>
        <!-- SWFObject's dynamic embed method replaces this alternative HTML content with Flash content when enough 
             JavaScript and Flash plug-in support is available. The div is initially hidden so that it doesn't show
             when JavaScript is disabled.
        -->
        <div id="flashContent">
            <p>
                To view this page ensure that Adobe Flash Player version 
                10.0.0 or greater is installed. 
            </p>
            <script type="text/javascript"> 
                var pageHost = ((document.location.protocol == "https:") ? "https://" : "http://"); 
                document.write("<a href='http://www.adobe.com/go/getflashplayer'><img src='" 
                                + pageHost + "www.adobe.com/images/shared/download_buttons/get_flash_player.gif' alt='Get Adobe Flash player' /></a>" ); 
            </script> 
        </div>

        <noscript>
            <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%" id="ActionscriptProject">
                <param name="movie" value="ActionscriptProject.swf" />
                <param name="quality" value="high" />
                <param name="bgcolor" value="#ffffff" />
                <param name="allowScriptAccess" value="sameDomain" />
                <param name="allowFullScreen" value="true" />
                <!--[if !IE]>-->
                <object type="application/x-shockwave-flash" data="ActionscriptProject.swf" width="100%" height="100%">
                    <param name="quality" value="high" />
                    <param name="bgcolor" value="#ffffff" />
                    <param name="allowScriptAccess" value="sameDomain" />
                    <param name="allowFullScreen" value="true" />
                <!--<![endif]-->
                <!--[if gte IE 6]>-->
                    <p> 
                        Either scripts and active content are not permitted to run or Adobe Flash Player version
                        10.0.0 or greater is not installed.
                    </p>
                <!--<![endif]-->
                    <a href="http://www.adobe.com/go/getflashplayer">
                        <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash Player" />
                    </a>
                <!--[if !IE]>-->
                </object>
                <!--<![endif]-->
            </object>
        </noscript>     
   </body>
</html>

Browsers

在 Chrome 中没有问题。所有应用程序加载速度都非常快(我估计在 3 秒内)。

在 IE 8 中这个问题很小。

在 IE 7 和 Firefox 3.6.17 中,页面加载需要很长时间。我没有在其他浏览器中测试过。
在 Firefox 中,页面加载大约需要 34 秒。

调试信息(火狐)

总共System.totalMemory据报道,swf 使用的总内存约为 42 MB。

以下是 Firebug 中“网络”选项卡的屏幕截图:

Full Size Image https://i.stack.imgur.com/9qqmb.jpg enter image description here

问题

  1. 有没有好的方法可以将多个相同的 swf 嵌入到网页中?
  2. 为什么 IE 和 Firefox 的表现如此糟糕?我怀疑这与 IE 和 Firefox 都只有一个线程来运行插件(Flash)有关。
  3. 我有一个用 AS2 编写的类似应用程序(不是我写的,我只有 swf 文件)。它要复杂得多,但在 IE 和 FF 中加载速度要快几个数量级。 AS3 固定浏览器而 AS2 不固定,这是否有原因?
  4. 如何在不固定浏览器的情况下将多个 AS3 swf 嵌入到 FF 和 IE 7 中?
  5. 有没有办法让应用程序变得更轻量?

您是否尝试过构建一个容器 swf,它本身会加载其他 swf?这可能会更快,因为这样 Firefox 就不必一次又一次地处理初始化 swf 的开销。创建一个空白电影来加载一堆其他电影并将它们放置在网格中是相当简单的。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Flash:同一页面上有许多相同的 SWF 的相关文章

  • C# - 获取所有 Firefox 实例中所有打开的浏览选项卡

    如何获取 Chrome 和 Firefox 打开页面的 URL https stackoverflow com questions 7814027 how can i get urls of open pages from chrome a
  • 如何抑制 IE9 window.close() 确认消息

    应用 window close 函数后 IE9 会引发 您正在查看的网页正在尝试关闭 消息 有没有办法在不更改应用程序代码的情况下 而是通过更改一些特定于 IE 的注册表项来抑制此消息 如果窗口不是由脚本打开的 IE 不允许在没有确认的情况
  • AS3 [Event(name="", type="")],有什么意义?

    我使用 FlashDevelop3 R2 和 Flex 3 3 SDK 进行开发 在很多情况下我必须使用嵌入元数据标签 如下所示 Embed source path to file private var Asset Class 我很好地理
  • 这个 HTML5
    元素有什么问题?

    div div
  • Bootstrap Glyphicons 在 IE10 或 FF 中不显示

    我无法在 IE10 或 FF 中显示引导字形图标 我正在使用最新的 bootstrap 3 代码 并以标准方式包含字形 span class glyphicon glyphicon edit span 它们在 Chrome 中工作正常 但在
  • Flash 照片上传 - 从网络摄像头拍摄照片 [关闭]

    就目前情况而言 这个问题不太适合我们的问答形式 我们希望答案得到事实 参考资料或专业知识的支持 但这个问题可能会引发辩论 争论 民意调查或扩展讨论 如果您觉得这个问题可以改进并可能重新开放 访问帮助中心 help reopen questi
  • 为什么反编译swf文件时jpexs工具不起作用?

    有人知道如何反编译 SWF 文件吗 我尝试过 JPEXS 和 Sothink SWF Decompiler 但不起作用 我把这个 swf在这个link https drive google com file d 1ehHprPOqR0QnR
  • 为什么 Firefox 3.6 改变了 jQuery 和 CSS 属性?

    为什么 Firefox 3 6 改变了 jQuery 和 CSS 属性 好吧 更具体一点 我有一个交叉淡入淡出插件 可以在放置在彼此之上的两个图像之间创建发光效果 该函数 如下所示 将使顶部图像在悬停时在 200 毫秒内转换为不透明度 0
  • Selenium Webdriver - Firefox 中元素不可点击错误

    通常在 Chrome 驱动程序中出现的元素不可点击错误也恰好在 Firefox 中出现 显示的错误消息 Exception in thread main org openqa selenium WebDriverException Elem
  • 如何从 JW Player 5.1 中提取 .flv 流?

    问题是我的互联网连接速度很慢 并且视频不像 YouTube 那样缓冲 因此我想知道是否可以提取 JW Player 中正在流式传输的 flv 文件的 url 并直接下载它 做了一些初步研究 我发现了以下信息 主要视频网址 http ijf1
  • 在 C# 中加密并在 Flex 中解密

    我需要解密 Flex 中的一些数据 这些数据是用 C 加密并写入文件的 为了简单起见 我选择使用 as3crypto As3 库和 Bruce Schneier C 库 AS3 as3加密链接 http code google com p
  • 无法在 IE 中的选择选项上使用 onmouseover 事件

    更新的代码 function getElements var x document getElementsByTagName option var el document getElementById selectDept el onmou
  • 将 < 或 > 运算符作为参数传递给函数?

    我的函数里面有一个if 像这样的声明 if passedValue lt staticValue 但我需要能够传递一个参数来指示 if 表达式是像上面那样还是 if passedValue gt staticValue 但我真的无法通过 l
  • 使用jquery调用AS3外部接口

    我正在使用ExternalInterface 调用嵌入在html 页面中的Flash 应用程序 以下代码工作正常 我正在使用按钮进行测试 document ready function button click function var a
  • IE6刷新时内存泄漏?

    我每隔几秒钟重新加载一个页面以从服务器获取更新 该页面可以打开并且这种情况可能永远发生 我猜测 特别是因为该浏览器位于未关闭的远程服务器上 我这样做 setTimeout function location href location hr
  • 在 Javascript 中检测 Flash 文件何时完成播放

    我正在使用 Javascript 将 Flash 文件嵌入到网站中 然后需要在播放完成后将其删除 有没有办法用普通的 Javascript 来做到这一点 或者是否需要将回调类型的函数添加到 Flash 文件本身 我该如何编码 JavaScr
  • grid-auto-columns 在 Firefox 中不能完全工作

    我不明白为什么 DIV 3 的大小与 DIV 1 DIV 2 的大小不同 https codepen io anon pen vaVqPW https codepen io anon pen vaVqPW grid display grid
  • jQuery输入文件点击方法和IE上拒绝访问

    我尝试仅使用一个按钮作为输入文件 它在 Firefox Chrome Safari 中工作正常 但在 IE 中不行 提交表单时我总是收到 访问被拒绝 的消息 代码 input file click 有真正的解决方法吗 我在谷歌上浪费了大约2
  • 使用 jQuery 选择具有数据属性的元素为其父元素分配一个 null ID

    这确实很奇怪 如果我使用 jQuery find 在滚动事件期间查找具有数据属性的子元素 然后滚动页面将重复添加和删除 IDparents这些元素 这很难描述 但这里有一个可重现的测试用例 http jsfiddle net 8fouvx9
  • 有没有办法将 SWF 转换为 SVG 格式?

    有没有办法将 FLA 或 SWF 转换为 SVG 格式 它可以是一个软件吗 或者甚至是网络转换器 我尝试了一些方法 但没有一个有效 所有这些似乎都已经过时了 不 SWF 支持的功能太多 而 SVG 格式无法创建有效的 SWF 版本 如果您只

随机推荐