15 August 2011
The Flash Platform lets you build rich, user experiences. The Facebook Platform lets you build rich, social experiences. Put the two together, and you can build killer applications incorporating social capabilities in highly interactive, expressive, and responsive applications.
This article introduces you to the architecture of applications built using the Flash and Facebook Platforms. It provides an overview of the different types of applications you can build and how the applications communicate with your server and Facebook.
Be sure to also read the article, The technologies for building applications on the Flash and Facebook Platforms.
You can build four types of Flash Platform applications to integrate with Facebook: applications on Facebook, external web applications, desktop applications, and mobile applications.
When a user requests an application on Facebook.com (for example, http://apps.facebook.com/someapp/), Facebook returns a Facebook web page with the Facebook chrome that contains an iFrame into which your application is loaded (see Figure 1).
As the user interacts with your application, several things may occur:
Note: You can also place a small set of FBML tags in your application that work in conjunction with the JavaScript SDK which scans the DOM for the tags and then sends the API requests to Facebook.
Now that we have covered the basics of non-Flash Platform applications on Facebook.com, let's take a look at integrating Flash Platform content into your application (see Figure 2).
Due to security restrictions of Flash Player, SWF files can only make data calls to the server from which the SWF file was served (that is, your server) or to servers that have a crossdomain policy file listing the server that the SWF file came from. This means that for your SWF file to make calls directly to the Facebook server, the Facebook server must have a crossdomain policy file giving SWF files from your server access. If you take a look at the Facebook cross-domain policy file, you will see a wildcard entry granting access to SWF files from all servers.
<cross-domain-policy>
<site-control permitted-cross-domain-policies="master-only"/>
<allow-access-from domain="*" secure="false"/>
</cross-domain-policy>
External Flash and Facebook Platform web applications (see Figure 3) are very similar to web applications on Facebook.com. The main difference is how you handle user login and application authorization. Instead of simply redirecting the browser to Facebook login and/or authorization pages, you use the Facebook JavaScript SDK in conjunction with the Adobe ActionScript 3 SDK for Facebook Platform to display the Facebook login and/or authorization pages in a pop-up window. Although the Facebook login is handled with JavaScript, you usually don't need to write any JavaScript code; you just call methods of classes in the Adobe ActionScript 3 SDK for Facebook Platform. Internally what happens is that code in the ActionScript SDK (specifically methods in the facebook.graph.core.FacebookJSBridge class) calls methods of the Facebook JavaScript SDK. The wrapper page for the application must include the Facebook JavaScript SDK.
Next, let's look at the architecture of Flash and Facebook Platform desktop applications (see Figure 4). Desktop applications are very similar to external Flash and Facebook Platform web applications, except that the SWF lives on the user's computer after the user installs the application and login is handled solely by the Adobe ActionScript 3 SDK for Facebook Platform. To deploy a Flash Platform application as desktop application, you create an AIR application for users to install.
Flash and Facebook mobile applications are like desktop applications; the application lives on the user's device after the user installs the application and login is handled solely by the Adobe ActionScript 3 SDK for Facebook Platform. On Android and Blackberry Tablet OS devices, the application is deployed as an AIR application (see Figure 5).
For deployment on iOS devices, the AIR application must be converted to a native iOS application using Flash Builder 4.5 or later or Flash Professional CS5 or later and then deployed (see Figure 6).
This article presented architecture diagrams and process flows for non-Flash Platform applications on Facebook.com, Flash Platform applications on Facebook.com, external Flash and Facebook Platform web applications, Flash and Facebook Platform desktop applications, and Flash and Facebook Platform mobile applications..
For detailed steps on creating a Flex and Facebook application that is deployed as either a desktop application, an external web application, or an application on Facebook.com, complete the tutorial series Create your first Flex and Facebook application.

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License