RSS
 

Facebook AS3 api Facebook.init() and .login() not Callback Not Called

26 Jun

Just a quick one because i have wasted 2 days on this issue already, i need to get back to work

I have a problem with Facebook graph api where the callback method or function is not being called.

Facebook-as3-api uses javascript to transport the response from the facebook popup back to flash.
For those who dont know, the javascript bridge file is no longer required as it has been replaced with an actionscript version.

back to the solution to your problem. the problem that brought you here.

here are the check lists of what you need to get actionscript working with facebook properly

1. you need 2 javascript file all.js and swfobject.js in the <head></head> section of your page to get this to work at all
you can include the remote versions like this

<script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js”></script>
<script type=”text/javascript” src=”http://connect.facebook.net/en_US/all.js”></script>

though i prefer saving a local copy and using that. reason is because some companies will restrict certain websites and i dont want that to mess up my application.

 

2. you need to add a special div at the top of your page, right after the opening body tag <body>

<div id=”fb-root”></div>

 

3.  use this snippet to embed your flash movie

<script type=”text/javascript”>
swfobject.embedSWF(“yourfile.swf”, “flashContent”, “1000”, “700”, “9.0”, null, null, null, {name: “flashContent”});

</script>

 

4. Last and the most important of all. Do all your facebook stuff in the Main timeline of your flash application.
use classes and import them freely but make sure you call your Facebook.init() and login() from the main timeline and that the handler function if on this timeline.

somehow, i figured the event gets thrown to the main timeline and wont reach the instance that called it.
this issue also happens with NetConnection when working with a media server. the way out with that it to do a nc.client=this

right inside the class so that updates are forwarded to that class instance when using SharedObjects

 

i hope this helps someone out there

 

 
 

Leave a Reply