AS3:获取浏览器窗口的大小?

编程入门 行业动态 更新时间:2024-10-24 08:25:53
本文介绍了AS3:获取浏览器窗口的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我可以在获取浏览器窗口的大小,AS3?

Can I get the obtain the size of the browser window in AS3?

我发现最好的方法是让大小的JavaScript,并将其发送到Flash作为一个Flash变量。这种方法的一个限制是,它不给当前的大小,如果窗口大小改变

The best method I've found is to get the size with Javascript and send it to Flash as a FlashVar. One limitation of this method is that it doesn't give the current size if the window is resized.

有没有一种纯粹的闪存办法做到这一点?

Is there a pure Flash way to do this?

推荐答案

这取决于如果你想你的swf设置为全屏,或简单地获取窗口尺寸用于其他目的。

It depends if you are trying to set your swf to fullscreen, or simply obtain window dimensions for some other purpose.

如果你正在做的全屏,你需要设置你的一个StageScaleMode 以NO_SCALE,并嵌入您的Flash对象插入一个div,有其高度,并设置为100%宽度参数。为了解决大小调整,您的Flash项目需要一个调整大小事件侦听器(适用于舞台),和所有的显示对象需要到调整大小的监听器做出反应。一旦您的SWF被调整得当,就可以了,前面已经提到的,使用stage.stageHeight / stageWidth从内部获取精确的尺寸。

If you are doing fullscreen, you need to set your stageScaleMode to NO_SCALE, and embed your flash object into a div that has its height and width parameters set to 100%. To deal with resizing, your flash project needs a resize event listener (applied to the stage), and all display objects need to respond to that resize listener. Once your swf is resizing properly, you can, as already noted, use stage.stageHeight / stageWidth to retrieve exact dimensions internally.

如果,在另一方面,你只是想获取窗口dimesions,你需要使用 ExternalInterface的进行的JavaScript调用。 jQuery有快速获取屏幕dimentions一些很好的工具。然后发送的数据回闪它只是一个问题。请记住,JavaScript有resize事件,以及,那你可以用它来强制闪光状态更改。

If, on the other hand, you just want to obtain the dimesions of the window, you will need to use ExternalInterface to make a javascript call. jQuery has some nice tools for quickly obtaining screen dimentions. Then its just a matter of sending that data back into flash. Remember that javascript has a resize event, as well, and that you can use it to force state changes in flash.

您是在最初的一段序列正确的 - 在负载发送FlashVars的,但屏幕大小的变化做出反应,你需要利用这些技术中的一种

You're correct in the initial piece of the sequence - sending flashvars in on load, but to respond to screen size changes, you will need to apply one of these techniques.

好运气

更多推荐

AS3:获取浏览器窗口的大小?

本文发布于:2023-11-23 15:48:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1622010.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:浏览器   大小   窗口

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!