使用 SWFObject 加载时调整 SWF 的大小 [英] Resize an SWF when loading it with SWFObject

查看:27
本文介绍了使用 SWFObject 加载时调整 SWF 的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 SWFObject 将 SWF 电影加载到 HTML 页面中.我想动态调整此 SWF 的大小.SWFObject 如何提供帮助?我确定我不必编写自己的解决方案.

解决方案

最简单的解决方案是将 SWF 嵌入到容器 div 中,然后使用 JavaScript 和 CSS 动态调整容器 DIV 的大小.如果 SWF 设置为 100% 宽度/高度,则只要调整包装器的大小,它就会拉伸以适合包装器.

在正文中:

<div id="flash">这个 div 将被一个通过 SWFObject 的对象替换</div>

在头脑中:

<style type="text/css">#闪光 {显示:块;宽度:100%;高度:100%;}</风格>

现在,每当您调整 #wrapper 的大小时,SWF 都会缩放以填充它.

I'm loading an SWF movie into an HTML page using SWFObject. I want to resize this SWF dynamically. How can SWFObject help? I'm sure I don't have to write my own solution.

解决方案

The easiest solution is to embed the SWF within a container div, then use JavaScript and CSS to dynamically resize the container DIV. If the SWF is set to 100% width/height, it will stretch to fit the wrapper whenever the wrapper is resized.

In the body:

<div id="wrapper">
<div id="flash">This div will be replaced by an object via SWFObject</div>
</div>

In the head:

<script>
var flashvars = {};
var params = { scale: "exactFit" };
var attributes = {};

swfobject.embedSWF("myContent.swf", "flash", "100%", "100%", "9.0.0","expressInstall.swf", flashvars, params, attributes);
</script>

<style type="text/css">
#flash {
   display: block;
   width: 100%;
   height: 100%;
}
</style>

Now whenever you resize #wrapper, the SWF will scale to fill it.

这篇关于使用 SWFObject 加载时调整 SWF 的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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