开发者

Flash (wmode=window) disappears after calling facebook dialog

We are writing app for facebook. It's a game written in flash and embeded with wmode window. We get problem with Firefox 6, but only开发者_JAVA百科 on Windows XP. When user invoke some facebook dialog (for example: pay dialog or buying more credits dialog) flash disappears. This same happens when user click on notifications (globe icon in top facebook menu) and hold it for a while (however this is not so important).

After flash disappears it it still in DOM as <object>. This is not happen when wallpost dialog is created.

How to fix it?

We can't change wmode, so this way is impossible.


The FB.init documentation: https://developers.facebook.com/docs/reference/javascript/FB.init/#flash gives you some options for doing something better than displaying a white background if your application will not work with 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜