Flash (wmode=window) 在调用 facebook 对话框后消失

标签 flash facebook firefox swfobject firefox6

我们正在为 facebook 编写应用程序。这是一个用 flash 编写并嵌入 wmode 窗口 的游戏。我们在 Firefox 6 上遇到问题,但仅限于 Windows XP。当用户调用某些 facebook 对话框(例如:支付对话框或购买更多积分对话框)时,flash 会消失。当用户单击通知(顶部 facebook 菜单中的地球图标)并按住它一段时间(但这并不那么重要)时,也会发生同样的情况。

flash 消失后它仍然在 DOM 中为 <object> . 创建墙报对话框时不会发生这种情况。

如何解决?

我们不能改变wmode,所以这种方式是不可能的。

最佳答案

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.

关于Flash (wmode=window) 在调用 facebook 对话框后消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7332546/

相关文章:

javascript - document.execCommand ('heading' ..') 在 Chrome 中

c# - 将 Flash 转换为 C# 时出错

javascript - 单击时显示 FB 状态更新弹出窗口?

angularjs facebook-login 获取用户数据

ios - 有没有一种方法可以在用户时间轴上自动显示 OpenGraph 操作,而无需他们从事件日志中启用它?

firefox - SVG 使用标签不渲染渐变 Firefox

flash - 从自定义形状 mask ActionScript 3 中保存裁剪的图像

flash - 阶段调整大小并获得正确的变量

javascript - ASP.net 使对象可点击

Firefox 3.6 忽略 CSS3 边框半径