First Go with the Facebook Actionscript API
I recently worked on a simple flash app for a facebook canvas page, this gave me the opportunity to give the facebook-actionscript-api a wee try. Overall I was really pleased with it, most of the pitfalls I ran into were more around Facebook than the api. I thought I’d post about my gotchas in case somebody is building something with similar functionality.
The app was for Ladbrokes for the up and coming Irish Grand National. It allowed you to superimpose your friend’s portrait on to some hoarse racing characters.
The app needed to do the following things
- Load all the user’s friends
- Display their friend’s portrait
- Post to user’s wall via the Facebook UI
- Post to the user’s friends’ wall
Gotcha #1 No flash example
The first gotcha was finding a flash example of the API, I’d quickly skimmed the examples but they all seemed to be flex. There is a flash example in there though that I missed, it’s under ‘FlashWebExample’ - cryptic.
Gotcha #2 Couldn’t Post to the Wall
This wouldn’t have been much of a problem had I bothered to setup proper logging. I normally just log to the console for flash stuff but firebug didin’t seem to work with it, no doubt because of the iframe or something. Anyhow I had orginally added my app without the permission to post to my wall, and as such was just getting a persmission error back from facebook. A look through the calls in firebug identified this so it wasn’t really a big problem, but just took a little longer to track down without a logger.
Gotcha #3 “SecurityError: Error #2000: No Active Security Context” when changing the portrait dimensions
This was simply because I was loading the portrait images off the external(facebook) server. You basically just need to include LoaderContext with your request and set checkPolicyFile to true. This blog gives an example.
If you’re using an iframe and loading something off you’re site then you’re generally best using full URLs.
Gotcha #4 Facebook.ui not appearing in IE8
This last problem took a bit of time to track down, especially since it occurred in the as3-facebook-api example as well. Basically if you use the Facebook.ui call to post to the user’s wall then you should get a facebook style dialog appear allowing the user to confirm the message. This worked fine in Firefox and Chrome but IE8 let me down. The problem turned out just to be that dialog was appearing behind the flash. Setting the wmode to ‘opaque’ sorted it.