- Flash Facebook Cookbook
- James Ford
- 699字
- 2021-04-02 18:51:30
Including the Facebook ActionScript 3 SDK as a Flash Builder library project
An alternative to including the Facebook AS3 SDK in its precompiled SWC form is to set up the SDK as a Flash Builder library project.
The end result, as far as the compiler and the user are concerned, is no different, but our own way of developing, reusing, and exploring the code is a little simpler. And unlike the precompiled SWC files that can be downloaded from the GitHub repositories, by using a Flash Builder library project, we can make modifications to the source code.
Using a Flash Builder library project makes it easy to reuse the code in the library in multiple other projects, and for the remaining recipes in this cookbook we're going to be linking to the library projects that we set up in this recipe.
There are two versions of the Facebook ActionScript 3 SDK, and just as there are two versions of the precompiled SWC to download, we will also need to create two Flash Builder library projects. In this recipe we're going to cover setting both of these library projects up and linking to these library projects from other projects.
How to do it...
- Create a new library project in Flash Builder, using the basic Flex SDK only (don't include the Adobe AIR libraries), and call it Facebook Web SDK.
- Copy the files and folders from the downloaded facebook-actionscript-api folder to the root folder of our project, setting up the following folder structure:
That will create a library project which we can use in basic Flash Player-based web projects. Next, we'll create a project that gives us the Adobe AIR version of the SDK.
- Keep the Facebook SDK Web project open, and create a new Flash Builder library project; call it the 'Facebook Desktop SDK', only this time, be sure to include the Adobe AIR libraries in your project.
- As with the web version of the SDK, copy the files you've downloaded from the facebook-air-api folder into our new library project, creating the following folder structure:
Not much to see in terms of source code, is there? Unlike the web version of the SDK, the desktop version isn't completely standalone; it relies on core classes from the web project—so what we need to do now is add the web project to the desktop project as a linked library.
- Open your project preferences, go to the Flex Library Build Path and then the Library path' tab, then click Add Project... and select the Facebook Web SDK project.
Once the web project is added as a library for the desktop library project, both of those projects should be able to compile, and that's it for this recipe.
How it works...
The complexity in this setup is just realizing that the Desktop version of the SDK is not a standalone library, and does, in fact, require all of the code from the web version. The source code files aren't duplicated for both versions because that would make things more complex to manage, and rather than merging the two sets into a single library project, we have to set things up in a way that keeps all of the AIR-specific source code in its own project.
Both versions of the Facebook ActionScript 3 SDK—Web and Desktop—rely on a core set of classes. The source code for the web version of the library contains all of these classes, whereas the desktop version of the library contains only the classes that require the AIR libraries, which is why it needs to be set up like this—to inherit those core files from the web project.
There's more...
The original release version of the Graph API—version 1.0—included an additional JavaScript file—the FBJSBridge.js
file. Since version 1.5 of the SDK there's no need for this additional JavaScript file—the Facebook ActionScript 3 SDK works to inject the original contents of that file into the containing HTML page, removing the necessity for those additional files, leaving only the ActionScript SDK as a requirement.
See also
- Including the Facebook ActionScript 3 SDK in a Flash Builder project
- Vue.js前端開發技術
- Joomla! 1.5 Site Blueprints
- 軟件定義數據中心:技術與實踐
- Talend Open Studio Cookbook
- 人臉識別算法與案例分析
- ADOBE FLASH PROFESSIONAL CS6 標準培訓教材
- ASP.NET jQuery Cookbook
- AI繪畫實戰:Midjourney從新手到高手
- 計算機圖形圖像處理Photoshop CS6項目教程
- 中文版Photoshop CC平面設計實用教程
- Oracle Enterprise Manager Grid Control 11g R1: Business Service Management
- 蝶變:移動用戶體驗設計之道
- Adobe創意大學Premiere Pro影視剪輯師標準實訓教材(CS6修訂版)
- Joomla! E/Commerce with VirtueMart
- Moodle 1.9 for Design and Technology