Resize an SWF when loading it with SWFObject

烂漫一生 提交于 2019-11-27 01:59:21

问题


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.


回答1:


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.




回答2:


Check out swffit, it should fit the bill perfectly.




回答3:


This did not work for me but did some small changes as indicated in http://code.google.com/p/swfobject/wiki/faq section "How can I create a SWF that will encompass 100% of the browser window?"

as this

<style type="text/css" media="screen">
  html, body, #containerA, #containerB { height:100%; }
  body { margin:0; padding:0; overflow:hidden; }
</style>

and perfect!




回答4:


I believe the code above should read:

#wrapper {
   display: block;
   width: 100%;
   height: 100%;
}


来源:https://stackoverflow.com/questions/952732/resize-an-swf-when-loading-it-with-swfobject

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!