我有一个网站,我使用 .swf 文件收集 Flash 屏幕分辨率数据以及来自 JavaScript 的相同数据,并将其发送到我的服务器。
对于某些用户来说,此数据看起来有误 - Flash 分辨率偶尔会大于或小于浏览器中报告的屏幕分辨率。
例如,一位用户在 JavaScript 中报告的屏幕分辨率为 1600x900
,但在 Flash 中报告的屏幕尺寸为 1366x768
。
我使用的 ActionScript 属性是:
flash.system.Capability.screenResolutionX
flash.system.Capability.screenResolutionY
我使用的 JavaScript 属性是:
window.screen.width
window.screen.height
在任何情况下,人们会期望这些值在 ActionScript 或 JavaScript 中始终不正确吗?
最佳答案
我认为问题在于 Flash Player 的 flash.system.Capability.screenResolutionX/Y
属性仅报告主显示器的分辨率。 (正如@akmozo对该问题的评论中提到的)
来自documentation :(强调我的)
This property does not update with a user's screen resolution and instead only indicates the resolution at the time Flash Player or an Adobe AIR application started. Also, the value only specifies the primary screen.
在 JS 中(这可能取决于浏览器),window.screen.width/height
将根据浏览器窗口所在的实际监视器进行报告。
因此,您的差异可能是在浏览器窗口不在主显示屏上的情况下出现的。 (因此 AS3 报告主显示器,JS 报告正在使用的实际显示器)
如果您需要使用 Flash 并获得准确的值,我建议使用以下技术之一:
使用
stage.fullScreenWidth
和stage.fullScreenHeight
值来获取当前显示器的分辨率。使用ExternalInterface并从 JavaScript 获取数据:
if(ExternalInterface.available){ var screenW:int = int(ExternalInterface.call("window.screen.width")); var screenH:int = int(ExternalInterface.call("window.screen.height")); }
关于javascript - flash.system.Capability.screenResolutionY 和 flash.system.Capability.screenResolutionX 的报告值是否不正确?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31926064/