调用Facebook对话框后,Flash(wmode = window)消失了

3
我们正在为Facebook编写应用程序。这是一个用Flash编写的游戏,并嵌入了"wmode window"。我们在Firefox 6上遇到了问题,但仅限于Windows XP。当用户调用一些Facebook对话框(例如:付款对话框或购买更多积分对话框)时,Flash会消失。当用户单击通知(位于Facebook顶部菜单中的全球图标)并保持一段时间时,也会发生同样的情况(然而这不是很重要)。
Flash消失后,它仍然存在于DOM中作为。创建Wallpost对话框时不会出现这种情况。
如何修复?
我们无法更改wmode,因此这种方法是不可能的。
1个回答

4

FB.init文档: https://developers.facebook.com/docs/reference/javascript/FB.init/#flash 提供了一些选项,如果您的应用程序不支持wmode="opaque",可以更好地解决白色背景的显示问题。

Adobe Flash applications on facebook.com

For Canvas applications using Adobe Flash, wmode="opaque" is preferred whenever possible. We have found that, on modern browsers with hardware compositing, there is generally no performance degradation to using wmode="opaque". Otherwise, Facebook will, by default, hide your Flash objects when popup events occur, and redisplay them when the popup is dismissed.

If you need to use wmode="window", and would like to control this behavior (such as also showing text or an image when this happens) you can provide a function into the hideFlashCallback parameter to FB.init. hideFlashCallback takes a state field as part of the passed in parameters saying whether the window is being opened or closed. This is the default implementation that you'll be overriding if you provide one, but may also give you an idea of what your override would look like:

function(params) {
  var candidates = window.document.getElementsByTagName('object');
  for (var i = 0; i < candidates.length; i++) {
    var elem = candidates[i];
    if (elem.type != "application/x-shockwave-flash") {
      continue;
    }

    var good = false;
    for (var j = 0; j < elem.childNodes.length; j++) {
      if (elem.childNodes[j].nodeName == "PARAM" && elem.childNodes[j].name == "wmode") {
        if (elem.childNodes[j].value != "window" && elem.childNodes[j].value != "default") {
          good = true;
        }
      }
    }
    if (!good) {
      if (params.state == 'opened') {
        elem.style.old_visibility = elem.style.visibility;
        elem.style.visibility = 'hidden';
      } else if (params.state == 'closed') {
        elem.style.visibility = elem.style.old_visibility;
        elem.style.old_visibility = '';
      }
    }
  }
}

Note: Some UI methods like stream.publish and stream.share can be used without registering an app or calling this method. If you are using an app id, all methods must be called after this method.


请参阅 https://developers.facebook.com/docs/hideflashcallback/ 获取最新的最佳实践文档,其中包括添加屏幕截图的功能。 - Drew Hoskins

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接