重新调整flash对象的大小不正常

时间:2016-03-12 17:00:43

标签: javascript html css flash swfobject

我正在开设Flash画廊,对于这个画廊,我希望视频具有一定的尺寸。当我第一次开始工作时,闪光灯只会非常小,并且无法正确调整尺寸。昨晚深夜,我让它工作到正确的大小,但无论出于何种原因,它似乎占用整个body标签并将所有其他元素推入html元素。作为一个例子,我放了一个h1标签来展示它是如何做到这一点的。我正在使用swffit和swfobject来使闪存工作,但我几乎肯定问题在于swffit甚至是我的代码。我开始制作一个jsfiddle示例,但它非常繁琐,我试图放入任何flash对象。对此有任何帮助将非常感激。

SWFOBJECT:https://github.com/swfobject/swfobject.git

SWFFIT:http://swffit.millermedeiros.com/

HTML和JAVASCRIPT

<!doctype html>

<html lang="en">

<head>
    <meta charset="utf-8">

    <title>Flash Test</title>
    <meta name="description" content="Flash stuff">
    <meta name="author" content="SitePoint">

    <link rel="stylesheet" href="styles/style.css">
    <script src="js/swfobject.js"></script>
    <script src="js/swffit.js"></script>

    <script type="text/javascript">
        var height = window.innerHeight - 160;
        var width = window.innerWidth - 140;
        if ((height * 1.375) < width) {
            width = height * 1.375;
        } else {
            height = width / 1.375;
        }
    </script>

    <script type="text/javascript">
        var flashvars = {},
            //params = {wmode:"transparent"},
            params = {},
            attributes = {};
        swfobject.embedSWF("swfs/scoob.swf", "moviefun", width  -140, height  -160, "9.0.0", "js/swfobject.js", flashvars, params, attributes);
        swffit.fit("moviefun", "1", "1", width, height, true, false);
    </script>

</head>

<body>
    <script type="text/javascript">
        window.onresize = doResize;

        function doResize() {
            height = window.innerHeight - 160;
            width = window.innerWidth - 140;
            if ((height * 0.7175) < width) {
                width = height * 0.7175;
            } else {
                height = width / 0.7175;
            };
            swffit.fit("moviefun", "1", "1", width, height, true, false)
        }
    </script>
    <div>
        <h1 id="mainText">Hey there</h1>
        <div id="moviefun">It didn't work prob bc of internet explorer... if not though can't help ya......</div>
    </div>
    <script src="scripts.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-beta1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</body>

</html>

CSS

body {
    background-color: red;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    color: #FFFFFF;
    font-size: 10px;
}

#moviefun {
    position: absolute;
    top: 0px;
    left: 70px;
    background-color: red;
}

#mainText {
    background: yellow;
}

这是一个问题的形象,因为它小于它并且仍然将所有内容推入HTML标签

https://i.gyazo.com/6fc868e77cb8ddbb0f5e477f1b2caf17.png

1 个答案:

答案 0 :(得分:1)

调整SWF大小最好通过调整父容器的大小来处理。见Resize an SWF when loading it with SWFObject