【发布时间】:2012-06-20 02:20:27
【问题描述】:
有谁知道如何使 swf 文件居中,该文件会从每一侧裁切,而不仅仅是在不同的屏幕分辨率下保持居中的权利?
我希望它与本网站的横幅 http://www.mondoliving.com.au/ 类似。如果您更改屏幕分辨率或浏览器窗口大小,图像将保持在中心但不缩放,仅显示的宽度似乎会因每边的裁剪而改变。
我尝试使用适用于不同屏幕分辨率的 javascript,但首先将 swf 加载到左侧,然后将其居中,这似乎跳到了中心。我想知道是否有人新的不同,更顺畅的方式来做到这一点?我想知道是否可以使用 swf 中的 Action 脚本来完成??
我使用的javascript是:
<script type="text/javascript">
function centerSWF()
{
var sw;
if(parseInt(navigator.appVersion)>3)
{
if(navigator.appName=="Netscape"){sw = window.innerWidth-17;}
if(navigator.appName.indexOf("Microsoft")!=-1){sw = document.body.offsetWidth-0;}
}
var w = (sw-1500)/2;
document.getElementById("flashbg").style.width = sw+"px";
document.getElementById("flash").style.marginLeft = w+"px";
}
</script>
</head>
<body onload="centerSWF()">
然后我嵌入了 swf。
嵌入代码:
<div id="flash_box">
<div id="flashbg" class="flashbg">
<div id="flash" class="flash">
<object id="FlashID" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="1500" height="250">
<param name="movie" value="img/top14.swf" />
<param name="quality" value="high" />
<param name="wmode" value="opaque" />
<param name="scale" value="noborder" />
<param name="swfversion" value="9.0.45.0" />
<!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you don’t want users to see the prompt. -->
<param name="expressinstall" value="Scripts/expressInstall.swf" />
<!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. -->
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="img/top14.swf" width="1500" height="250">
<!--<![endif]-->
<param name="quality" value="high" />
<param name="wmode" value="opaque" />
<param name="swfversion" value="9.0.45.0" />
<param name="expressinstall" value="Scripts/expressInstall.swf" />
<!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. -->
<div>
<h4>Content on this page requires a newer version of Adobe Flash Player.</h4>
<p><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" width="112" height="33" /></a></p>
</div>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
</div>
</div>
</div>
<!--End flash_box -->
还有 CSS:
#flash_box {
margin:auto;
padding:0px 0px 5px 0px;
border-bottom:double #e9e8e8 thin;
border-collapse:collapse;
height:250px;
overflow:hidden;
}
.flashbg{position:absolute;overflow:hidden;}
.flash{width:1500px;}
谢谢 非常感谢任何帮助。
【问题讨论】:
-
请添加嵌入代码的HTML
-
对不起,我已将其添加到帖子中,
标签: javascript html flash