使用this.stage.browserZoomFactor时,编译提供
Error: Access of possibly undefined property browserZoomFactor
through a reference with static type flash.display:Stage.
return this.stage.browserZoomFactor;
哪个是不幸的,因为我在网上找不到任何人实际使用browserZoomFactor的例子。不知道如何解决这个问题,但欢迎所有建议。
相关代码段:
public function getZoomLevelInfo():Number {
return this.stage.browserZoomFactor;
}
答案 0 :(得分:1)
除非您使用的是IE,Windows 8,否则此功能无法正常运行。其他浏览器不报告浏览器缩放量,因此无法找到该属性。 http://blogs.adobe.com/flashplayer/2014/09/improved-resolution-of-stage3d-content-on-browser-zoom.html
答案 1 :(得分:1)
您似乎在静态引用中使用它。 在调用其属性之前,请确保该stage不为null。 如果定义了stage,则stage.browserZoomFactor应该可以正常工作。
尝试以下代码:
if ( stage === null ) trace("stage is null, it's a scope issue");
else trace("zoom factor:", stage.browserZoomFactor);