【问题标题】:How to check from javascript that flash object is in fullscreen mode如何从 javascript 检查 flash 对象是否处于全屏模式
【发布时间】:2025-12-01 17:05:01
【问题描述】:

我需要通过 javascript 检查给定的 flash 对象是否处于全屏模式。我知道有stage.displayState 属性但是如何使用GetVariable 访问它?或者也许还有其他方法?

谢谢。

附:如果您知道如何使用任何其他语言来做到这一点,那也没关系。

【问题讨论】:

    标签: javascript flash fullscreen


    【解决方案1】:

    您可能需要在 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

    希望对您有所帮助。干杯!

    【讨论】:

    • 别忘了在你的 html 包装器中将 allowScriptAccess 设置为 true
    • 谢谢,但这不是我的 Flash 对象,所以我无法修改它。我可以通过 ExternalInterface 获取 stage.displayState 而不更改 AS 代码吗?
    • @DennisJaamann 不错! :) Sergius 我不相信有办法在不改变 AS 代码的情况下读回这个属性。
    • @keeganwatkins:我明白了。再次感谢。