如何从javascript检查flash对象是否处于全屏模式

How to check from javascript that flash object is in fullscreen mode

本文关键字:是否 于全屏 模式 对象 flash javascript 检查      更新时间:2023-09-26

我需要从javascript检查给定的flash对象是在全屏模式。我知道有stage.displayState属性,但如何使用GetVariable访问它?或许还有别的办法?

谢谢。

注:如果你知道如何从其他语言中做到这一点,这也是可以的。

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

docs for ExternalInterface在这里,stage display state在这里。

希望有帮助。干杯!