Embedding flash object in Facebook Apps (FBML)

Yesterday I was trying to include a flash object in a facebook app using FBML fb:swf tag. The flash object needed to change the url of the page it was running on on a particular event. But since facebook prevents direct script access from flash, this could not be done.

Here is a simple workaround:

1. Create a simple html page containing only the flash object that you want to include.

      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   	<object type="application/x-shockwave-flash" data="foo.swf" width="300" height="300">
   		<param name="movie" value="foo.swf">
         	<param name="quality" value="high">
         	<param name="scale" value="noscale">
         	<param name="salign" value="LT">
         	<param name="menu" value="false">

2. Embed this html on the facebook page using the fb:iframe tag.

Now you can make all the Actionscript calls you want to. Only caveat to this approach is that you will no longer be able to make Facebook API calls directly from flash.