On my quest to make the facebook actionscript connectivity as easy to work with as possible I needed to be able to reproduce the
ExternalInterface.call(js, 'http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php');
First let's look at the code to embed the call into the head.
var head = document.getElementsByTagName('HEAD').item(0);
script = document.createElement('script');
script.src = src;
script.type = 'text/javascript';
head.appendChild(script);
This take sthe element on the html that is the head tag and creates a script element (pretty much just how it reads). the src is then pushed in through the call to ExternalInterface with
ExternalInterface.call(js, 'http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php');
Once I create this initial test I ran the call and my flash kept disappearing. I was like WTF!?!?
Then after going through the Facebook js code I realized there was a test to check if there was a hidden div container called FB_HiddenContainer in the html and if not then document.write() it. This overwrote the embedding code I was using to embed my flash thereby removing it totally from the page. I use the same type of method for the insertion of the script tag to insert a div tag in the body of the html as follows:
var body = document.getElementsByTagName('body').item(0);
div = document.createElement('div');
div.id = 'FB_HiddenContainer';
body.appendChild(div);
And voila! You now have a [script src='http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php'] making all FB methods available, as well as the [div id='FB_HiddenContainer'] container in the body to prevent that funkiness of removing your swf.
Hope this might be helpful to anyone wanting to do the same!
Leave a Reply
You must be logged in to post a comment.