swfobject没有回调swffit

时间:2013-07-04 16:13:21

标签: javascript swfobject

我有一个flash对象读取一些flashvars,我需要适合flash对象最小尺寸1000x600 ..如果它更大,那么它应该是100%x100%。 所以我使用swfit,我需要通过GET从php设置flashvars,flash内容是流动的。如果我使用宽度100%和高度100%它完美地工作,但正如我所说,如果你使用1000x600以下的分辨率,flash对象上的一些元素看起来不太好,这里是代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <title>My HTML Title</title>
        <script type="text/javascript" src="swfobject.js"></script>
        <script type="text/javascript" src="swffit.js"></script>
        <script type="text/javascript">
            var flashvars = {
                section:" <?php if (isset($GET_['section'])) { echo $GET_['section']; } else { echo 'home'; } ?>",
                previewid:" <?php if (isset($GET_['previewid'])) { echo $GET_['previewid']; } else { echo 'null'; } ?>",
                previewlikes:" <?php if (isset($GET_['previewlikes'])) { echo $GET_['previewlikes']; } else { echo 'null'; } ?>",
                previewdate:" <?php if (isset($GET_['previewdate'])) { echo $GET_['previewdate']; } else { echo 'null'; } ?>",
                previewurl:" <?php if (isset($GET_['previewurl'])) { echo $GET_['previewurl']; } else { echo 'null'; } ?>"
            };
            var params = {
                quality: "high",
                scale: "noScale",
                wmode: "transparent",
                allowscriptaccess: "always",
                bgcolor: "#000000"
            };
             var attributes = {
                id: "Container",
                name: "Container"
            };
            swfobject.embedSWF("Container.swf", "Container", "1000", "600", "9.0.0", false, flashvars, params, attributes, callbackHandler);
            var callbackHandler = function (e)
            {
                if (e.success)
                {
                    swffit.fit("Container",1000,600,2048,1536,false,false);
                }
            }
        </script>
        <style type="text/css">
            body
            {
                background-color: #000000;
            }
        </style>
    </head>
    <body>
        <div id="Container">
            <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" title="Get Adobe Flash player"/></a><br/>
            You need <a href="http://www.adobe.com/go/getflashplayer">Flash Player 9</a> and allow javascript to see the content of this site..
        </div>
    </body>
</html>

1 个答案:

答案 0 :(得分:0)

修正了,对于那里有相同错误的人来说是一个解决方案:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <title>My Title</title>
        <script type="text/javascript" src="swfobject.js"></script>
        <script type="text/javascript" src="swffit.js"></script>
        <script type="text/javascript">
            var flashvars = {
                section:" <?php if (isset($GET_['section'])) { echo $GET_['section']; } else { echo 'home'; } ?>",
                previewid:" <?php if (isset($GET_['previewid'])) { echo $GET_['previewid']; } else { echo 'null'; } ?>",
                previewlikes:" <?php if (isset($GET_['previewlikes'])) { echo $GET_['previewlikes']; } else { echo 'null'; } ?>",
                previewdate:" <?php if (isset($GET_['previewdate'])) { echo $GET_['previewdate']; } else { echo 'null'; } ?>",
                totalimages:" <?php if (isset($GET_['totalimages'])) { echo $GET_['totalimages']; } else { echo 'null'; } ?>"
            };

            var params = {bgcolor:"#000000"};

            var attributes = {id: "flash"};

            swfobject.embedSWF("Container.swf", "flash", "1000", "600", "9.0.0","",flashvars, params, attributes);
            swffit.fit("flash",1000,600,2048,1536);
        </script>
        <style type="text/css">
            body{
                background-color: #000000;
            }
        </style>
    </head>
    <body>
        <div id="flash">
            <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" title="Get Adobe Flash player" /></a><br />
            You need <a href="http://www.adobe.com/go/getflashplayer">Flash Player 9</a> and allow javascript to see the content of this site..
        </div>
    </body>
</html>