0

I know the standard way of handling the wmode problem is to register a callback that pauses the flash app and replaces the flash area with an image while the flash object is hidden.

What I'm trying to avoid is the flash disappearing in mid-game because of the facebook-chat auto-flyout when somebody sends a message the user (user's friends can essentially pause the user's game remotely, simply by sending them an instant message).

It seems as if Angry Birds Friends and Zynga's Ruby Blast Adventure have solved this problem somehow. These games run on stage3d so their wmode is set to 'direct', and when an instant message is received, facebook shows only a small new-message-indicator instead of displaying the full messages-dialog right away.

I can't figure out how they've managed to do that. For me, facebook always seems to pop up the messaging as soon as a message is received.

The game is in stage3d so having a wmode of 'direct' is a must.

Any help would be greatly appreciated.

syko
  • 415
  • 1
  • 5
  • 9

2 Answers2

0

I'm battling with the same issue, except imo the perfect solution would be to show both the chat (and other facebook menus) and the stage3d flash at the same time. It seems that setting the element containing the flash, e.g. div as:

display: block !important; 
visibility: visible !important; 

does the trick, but I'm not really confident that is the perfect solution.. It seems that on some browser/OS combination some (Facebook invoken) ui stuff is now shown behind the flash at least partially. Would appreciate a lot for "an official correct answer(tm)".

croop
  • 1
  • 1
0

You can write a listener function to be called when your game loses or regains focus, and register it with the Facebook environment by passing it to FB.init() as the hideFlashCallback parameter. The listener will be passed a parameters dictionary which will contain a key called state, which will be set to opened if you should be hiding your game.

In that case, the listener should call the Flash app's exportScreenshot method, use the Base64-encoded image data to create a data URL, and make that the src of an img element; it should move your app's containing element offscreen using the FB.hideFlashElement method in the JS SDK, and replace it with that img. If the parameters dictionary passed to the listener does not have state: "opened" then, instead, bring your Flash app back onscreen using FB.Canvas.showFlashElement.

You can find more information here: https://developers.facebook.com/docs/games/gamesonfacebook/optimizing#handlingpopups

Chris Hawkins
  • 724
  • 4
  • 15