【发布时间】:2025-12-01 17:05:01
【问题描述】:
我需要通过 javascript 检查给定的 flash 对象是否处于全屏模式。我知道有stage.displayState 属性但是如何使用GetVariable 访问它?或者也许还有其他方法?
谢谢。
附:如果您知道如何使用任何其他语言来做到这一点,那也没关系。
【问题讨论】:
标签: javascript flash fullscreen
我需要通过 javascript 检查给定的 flash 对象是否处于全屏模式。我知道有stage.displayState 属性但是如何使用GetVariable 访问它?或者也许还有其他方法?
谢谢。
附:如果您知道如何使用任何其他语言来做到这一点,那也没关系。
【问题讨论】:
标签: javascript flash fullscreen
您可能需要在 AS 中添加一个可以从 JS 层调用的函数:
// In your AS code
import flash.external.ExternalInterface;
import flash.display.StageDisplayState;
// Register a function you can call from JS
ExternalInterface.addCallback("isFullScreen", _isFullScreen);
// Returns true if fullscreen
private function _isFullScreen() :Boolean {
return stage.displayState === StageDisplayState.FULL_SCREEN:
};
那么,你应该可以从 JS 调用它:
// Get a reference to the object element, change
// 'flashcontent' to the ID of your .swf in the DOM
var o = document.getElementById('flashcontent'),
// Figure out it the player is in fullscreen mode
isFullScreen = o.isFullScreen();
// Do something with isFullScreen value
ExternalInterface 的文档here,舞台显示状态here。
希望对您有所帮助。干杯!
【讨论】:
allowScriptAccess 设置为 true