快讯:在同一个页面中有许多相同的主权财富基金 [英] Flash: Many identical SWFs on same Page

查看:204
本文介绍了快讯:在同一个页面中有许多相同的主权财富基金的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

摘要

我试图做一个网页,有多个上相同的SWF的。我有它是愚蠢加载速度慢的问题(下载时间是罚款虽然)。我有一个4×4表每个单元格中有嵌入的iframe的SWF文件。 。(注:4×4台=> 16主权财富基金)

我的AS3 code是很简单的:

 包
{
    进口flash.display.Sprite;
    进口flash.system.System;
    进口API元素flash.text.TextField;

    公共类ActionscriptProject扩展Sprite
    {
        公共职能ActionscriptProject()
        {
            VAR TXT:文本字段=新的TextField();
            txt.x = 0;
            txt.y = 0;
            txt.width = 5000;
            txt.height = 5000;
            的addChild(TXT);
            txt.htmlText + =&其中;字体大小='45'>中+ System.totalMemory / 1048576 +MB+&所述; /字体>中;
        }
    }
}
 

我使用这个网站加载的iframe:

 < D​​OCTYPE HTML PUBLIC -  // W3C // DTD HTML 4.01过渡// ENhttp://www.w3.org/TR/html4/loose! DTD>
< HTML>
< HEAD>
< META HTTP-当量=Content-Type的CONTENT =text / html的;字符集= ISO-8859-1>
<冠军>闪存测试与LT; /标题>
< /头>
<身体GT;

<表格边框=1>
    &其中; TR>
        < TD>
            < IFRAME ALLOWTRANSPARENCY ='真正的'滚动='没有'SRC ='闪光/ ActionscriptProject.html'>< / IFRAME>
        < / TD>
        < TD>
            < IFRAME ALLOWTRANSPARENCY ='真正的'滚动='没有'SRC ='闪光/ ActionscriptProject.html'>< / IFRAME>
        < / TD>
        < TD>
            < IFRAME ALLOWTRANSPARENCY ='真正的'滚动='没有'SRC ='闪光/ ActionscriptProject.html'>< / IFRAME>
        < / TD>
        < TD>
            < IFRAME ALLOWTRANSPARENCY ='真正的'滚动='没有'SRC ='闪光/ ActionscriptProject.html'>< / IFRAME>
        < / TD>
    < / TR>
    &其中; TR>
        ...
    < / TR>
    &其中; TR>
        ...
    < / TR>
    &其中; TR>
        ...
    < / TR>
< /表>

< /身体GT;
< / HTML>
 

注:ActionscriptProject.html就是这样的Flash Builder创建了应用标准的HTML。但在The_asMan的要求,我包括在这里:

 <!DOCTYPE HTML PUBLIC -  // W3C // DTD XHTML 1.0过渡// ENhttp://www.w3.org/TR/xhtml1/DTD/ XHTML1-transitional.dtd>
<  - 免于URL =(0014)约:互联网 - >
< HTML的xmlns =htt​​p://www.w3.org/1999/xhtml郎=ENXML:LANG =EN>
    <! - 
    聪明的开发商总是查看源文件。

    此应用程序是使用Adobe Flex,一个开源框架构建
    构建丰富的互联网应用程序,通过被传递
    Flash Player或通过Adobe AIR的桌面。

    了解更多关于Flex的http://flex.org
    //  - >
    < HEAD>
        <冠军>< /标题>
        < META HTTP-当量=Content-Type的CONTENT =text / html的;字符集= UTF-8/>
        <! - 包括CSS,以消除任何默认边距/填充和设置HTML元素的高度和
             主体元件100%,因为Firefox或任何基于Gecko浏览器,除$ P $点百分比
             其父容器,它必须被明确设置的高度的百分比。原来,
             不显示flashContent分区,这样就不会显示,如果禁用了JavaScript。
         - >
        <风格类型=文本/ CSS媒体=屏幕>
            的HTML,身体{高度:100%; }
            身体{保证金:0;填充:0;溢出:汽车;文本对齐:中心;
                   背景色:#FFFFFF; }
            #flashContent {显示:无; }
        < /风格>

        <! - 用两个连字符替换useBrowserHistory令牌启用浏览器的历史记录 - >
        <! -  BEGIN浏览器历史记录所需的部分 - >
        <链接相对=样式类型=文/ CSS的href =历史/ history.css/>
        <脚本类型=文/ JavaScript的SRC =历史/ history.js>< / SCRIPT>
        <! -  END浏览器历史记录所需的部分 - >

        <脚本类型=文/ JavaScript的SRC =swfobject.js>< / SCRIPT>
        <脚本类型=文/ JavaScript的>
            <! - 对于版本检测,设置到最小。所需的Flash Player版本,或0(或0.0.0),因为没有版本检测。 - >
            VAR swfVersionStr =10.0.0;
            <! - 要使用EX preSS安装,设置为playerProductInstall.swf,否则空字符串。 - >
            VAR xiSwfUrlStr =playerProductInstall.swf;
            VAR Flash变量= {};
            变种PARAMS = {};
            params.quality =高;
            params.bgcolor =#FFFFFF;
            params.allowscriptaccess =导航特殊;
            params.allowfullscreen =真;
            变种属性= {};
            attributes.id =ActionscriptProject;
            attributes.name =ActionscriptProject;
            attributes.align =中间;
            swfobject.embedSWF(
                ActionscriptProject.swf,flashContent,
                100%,100%,
                swfVersionStr,xiSwfUrlStr,
                Flash变量,参数,可以属性);
            <! - 启用JavaScript,以便在情况显示flashContent DIV它不与SWF对象所取代。 - >
            swfobject.createCSS(#flashContent,显示:块;文本对齐:左;);
        < / SCRIPT>
    < /头>
    <身体GT;
        <! -  SWFObject的动态嵌入方法取代这种替代HTML内容与Flash内容不够时,
             JavaScript和Flash插件的支持是可用的。该分区最初是隐藏的,这样它不显示
             当禁用JavaScript。
         - >
        < D​​IV ID =flashContent>
            &其中p为H.;
                要查看此页面确保Adobe Flash Player版本
                10.0.0或更高安装。
            &所述; / P>
            <脚本类型=文/ JavaScript的>
                VAR pageHost =((document.location.protocol ==htt​​ps:开头)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 =获取Adobe Flash Player/>< / A>中);
            < / SCRIPT>
        < / DIV>

        < NOSCRIPT>
            <对象的classid =CLSID:D27CDB6E-AE6D-11CF-96B8-444553540000WIDTH =100%高度=100%ID =ActionscriptProject>
                < PARAM NAME =电影值=ActionscriptProject.swf/>
                < PARAM NAME =质量值=高/>
                < PARAM NAME =BGCOLOR值=#FFFFFF/>
                < PARAM NAME =allowScriptAccess的值=导航特殊/>
                < PARAM NAME =的allowFullScreen值=真/>
                <! -  [如果IE!]>  - >
                <对象类型=应用程序/ x-冲击波闪光数据=ActionscriptProject.swfWIDTH =100%高度=100%>
                    < PARAM NAME =质量值=高/>
                    < PARAM NAME =BGCOLOR值=#FFFFFF/>
                    < PARAM NAME =allowScriptAccess的值=导航特殊/>
                    < PARAM NAME =的allowFullScreen值=真/>
                <! - <![ENDIF]  - >
                <! -  [如果GTE IE 6]>  - >
                    &其中p为H.;
                        无论是脚本和活跃的内容不得运行或Adobe Flash Player版本
                        10.0.0或更高版本未安装。
                    &所述; / P>
                <! - <![ENDIF]  - >
                    &所述; A HREF =htt​​p://www.adobe.com/go/getflashplayer>
                        < IMG SRC =htt​​p://www.adobe.com/images/shared/download_buttons/get_flash_player.gifALT =获得Adobe Flash Player/>
                    &所述; / a取代;
                <! -  [如果IE!]>  - >
                &所述; /对象>
                <! - <![ENDIF]  - >
            &所述; /对象>
        < / NOSCRIPT>
   < /身体GT;
< / HTML>
 

浏览器

在铬是没有问题的。所有的应用程序加载速度非常快(我会在3秒钟内估计)。

在IE 8的问题是最小的。

在IE 7和Firefox 3.6.17的页面需要很长的时间来加载。我没有在其他浏览器进行测试。
在Firefox网页约需34秒加载。

调试信​​息(火狐)

在总共 System.totalMemory 报告指出,主权财富基金我们〜42 MB组合内存。

下面是一个屏幕截图Net标签的Firebug的:

全尺寸图像

问题

  1. 有嵌入多个相同的主权财富基金到网页的好办法?
  2. 为什么IE和Firefox挣扎如此糟糕?我怀疑它,是因为有一个事实,即IE和Firefox的每一个只能有一个线程来运行的插件(闪存)的
  3. 在我写在AS2一个类似的应用程序(不是我写的,我只是有SWF文件)。这是更复杂,但它加载快几个数量级在IE和FF。是否有一个原因,AS3引脚的浏览器时,AS2不?
  4. 如何嵌入多个AS3主权财富基金到FF&放大器; IE 7没有寄托的浏览器?
  5. 有没有一种方法,使一个应用程序,重量越来越轻?
解决方案

您是否尝试过构建自身加载其他主权财富基金的容器SWF?这可能会更快,因为那时火狐没有处理遍地初始化一个swf的开销。这是相当简单的创建一个空白的影片加载很多其他的电影,并将它们放在一个网格布局。

Summary

I am trying to make a web page that has multiple of the same SWF on it. I am having a problem with it being stupidly slow loading (download time is fine though). I have a 4x4 table in each cell there is a swf file embedded in an iframe. (Note: 4 X 4 table => 16 SWFS).

My AS3 code is very simple:

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>";
        }
    }
}

I am loading it in an iframe using this html:

<!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>

Note: ActionscriptProject.html is just the standard html that Flash Builder creates with the application. But at the request of The_asMan I am including it here:

<!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

In Chrome there is no problem. All of the apps load very quickly (I would estimate within 3 seconds).

In IE 8 the problem is minimal.

In IE 7 and Firefox 3.6.17 the page takes a very long time to load. I have not tested in other browsers.
In Firefox the page takes about 34 seconds to load.

Debug Info (Firefox)

In total System.totalMemory reports that the swfs us a combined memory of ~42 MB.

Here is a screen shot of the Net tab in Firebug:

Full Size Image

Questions

  1. Is there a good way to embed multiple identical swfs into a web page?
  2. Why are IE and Firefox struggling so poorly? I suspect it has to do with the fact that both IE and Firefox each only have one thread to run plugins (Flash) in.
  3. I have a similar app written in AS2 (not written by me, I just have the swf file). It is much more complex but it loads orders of magnitude faster in IE and FF. Is there a reason that AS3 pins the browser when AS2 does not?
  4. How can I embed multiple AS3 swfs into FF & IE 7 without pinning the browser?
  5. Is there a way to make an application that is more light weight?

解决方案

Have you tried building a container swf that itself loads the other swfs? That may be faster, because then Firefox doesn't have to deal with the overhead of initializing a swf over and over. It is fairly simple to create a blank movie that loads a bunch of other movies and places them in a grid arrangement.

这篇关于快讯:在同一个页面中有许多相同的主权财富基金的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆