gpt4 book ai didi

javascript - Swfobject 和 MooTools : Dynamic movie height

转载 作者:行者123 更新时间:2023-11-30 23:50:00 25 4
gpt4 key购买 nike

问候。

我正在为 Flash-HTML 混合网站开发动画主页,出于标准考虑,我的解决方案被证明很困难。我不是 Javascript 专业人士,因此非常感谢您的帮助!

以下是概要:

对于 Flash 用户,HTML 页面会加载可变高度的 AS3 Flash 影片,该影片将以556 像素高开始,并在完成其动画序列后,通过 Actionscript + JavaScript 补间到250 像素高

为了开始这个电影序列 - (左下) - 我正在尝试通过 MooTools 设置 Flash 电影的初始高度,因此如果用户没有启用 Flash 或 Javascript ,他们将看到高度较短的图像区域,其中显示了替代图像内容和 HTML 内容(右下)

Element.setStyle 将高度设置得很好,直到 swfObject 运行为止,此时影片会崩溃,因为我没有通过 CSS 指定高度。如果用户没有Flash,则默认为静态图像的高度。

所以这是我的问题:有谁知道当 swfobject 设置为 width/height @ 100% 时如何动态地将高度变量传递给 swfobject ?我是否会无缘无故地自杀尝试使用两个页面高度?

图像序列:
左 - 下面带有 HTML 导航的初始 Flash 影片
右 - 在序列末尾调整大小的影片,下面带有 HTML 导航和内容,看起来与无 Flash 版本(静态图像)相同

alt text http://client.deicreative.com/op/images/twopages.jpg

                                           ^^ should land here for users w/o Flash

<script type="text/javascript">
<!--
window.addEvent('domready', function() {
$('flashContent').setStyle('height', 556); // sets height for initial movie
$('homeContent').setStyle('display', 'none'); // hides homepage text + photos below
doSwfObject(); // attempting to start swfObject after setStyle is done
});
function resizePage(h) { // to be called from AS3
var tweenObj = new Fx.Tween('flashContent');
tweenObj.start('height', h);
}
function doSwfObject(){
var flashvars = {};
var params = { scale: "noScale" };
var attributes = { id: "flashContent", name: "flashContent" };
swfobject.embedSWF("swf/homeMovie.swf", "flashContent", "100%", "100%", "9.0.0", false, flashvars, params, attributes);
alert(document.getElementById('flashContent').style.height);
// alerts & shows correct height, but page collapses after hitting 'ok'
}
//-->
</script>

最佳答案

最简单的解决方案是将 SWF 嵌入到包装 DIV 中。将 SWF 设置为包装器 DIV 的 100% 宽度/高度,然后使用 JS 调整包装器 DIV 的大小,而不是 本身。这样就减少了 bug。

由于 SWFObject 2 将目标 DIV 替换为对象,因此您的标记中需要一个额外的 div:

<div id="wrapper">
<div id="flashcontent"></div>
</div>

变成了

<div id="wrapper">
<object id="flashcontent" width="100%" height="100%" (etc.) ></object>
</div>

关于javascript - Swfobject 和 MooTools : Dynamic movie height,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1725640/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com