Putting Your Flash Application on Facebook (iFrame)
After I read the book “Facebook Graph API Development with Flash“, I wanted to make a little application to test out what I had learned.
If you want to see what I came up with, you can try it here: http://apps.facebook.com/jello-friends/ (you’ll need a Facebook account)
Please notice that the actual iFrame width you have to your disposal, is 758 pixels, as facebook somehow eats up a pixel in each side. (Stackowerflow question)
I wanted to have this functionality: If the user is not logged in, or haven’t allowed the application to access the basic information about the user yet, redirect to the appropriate site (login / authorization), else display my SWF.
I had a great deal of trouble making this work, but finally found a way to do this.
I used version 1.5 of the official Adobe ActionScript 3 SDK for Facebook.
In addition to that I used a modified version of a index PHP file from the examples of the SDK.
I’ve made all the things you need to edit variables in this PHP file, so it should be VERY easy to use! (I also told robots that they shouldn’t crawl this, but feel free to remove that – line 3)
In your AS3 project, you simply just call:
Facebook.init ( "YOUR_APPLICATION_ID", initComplete ) ; |
Where the initComplete function must look something like this (at least accept the two obejct parameters):
function initComplete(success:Object, fail:Object):void { if (success is FacebookSession) { // we're good to go! } else { // something went very wrong! } } |
I did not actually use the SDK to make the calls inside my application, but I would not believe you would have to do any more than this to make it work!
- Review: Facebook Graph API Book
- Putting Your Flash Application on Facebook (iFrame)