How to resize a .swf file depending on screen size?

纵饮孤独 提交于 2019-12-12 05:26:30

问题


I have a website with a large .swf file. However when people with smaller screens view the website, I would like the .swf (which takes up the entire screen) to resize to fit on exactly. Just like how on most flash sites when viewed they fit the screen perfectly, however also then when viewed on computers with smaller screens they resize and still fit perfectly again.


回答1:


If you link directly to the swf file (not embedding it in any page) it'll be full-screen.




回答2:


You could generate the <object> tag which embeds the SWF file via JavaScript and print the width and height programmatically based on the size of the containing window. For example:

<script type="text/javascript">
  var w=window.innerWidth, h=window.innerHeight;
  document.write('<object width="' + w + '" height="' + h + '">');
  document.write('  <param name="movie" value="x.swf">');
  document.write('  <embed src="x.swf" width="100%" height="100%"></embed>');
  document.write('</object>');
</script>

The method for retrieving the window width/height will probably vary per browser but I'm sure you can find a reliable, cross-browser way to do it somewhere online.

If you need to dynamically resize whenever the window is resized then you can attach a handler to the window.onresize event which retrieves the necessary object and embed DOM elements and change their width and height properties. Probably. I haven't tested any of this.



来源:https://stackoverflow.com/questions/3122886/how-to-resize-a-swf-file-depending-on-screen-size

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