- 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
- UG NX10.0從新手到高手
- 數(shù)據(jù)、模型與決策:基于Excel的建模和商務(wù)應(yīng)用
- 設(shè)計模式之禪(第2版)
- SketchUp印象 城市規(guī)劃項目實踐(第2版)
- Photoshop CS6從入門到精通
- ABAQUS基礎(chǔ)入門與案例精通
- Photoshop CS6實戰(zhàn)從入門到精通(超值版)
- 新編 中文版Photoshop入門與提高
- 好用,Excel數(shù)據(jù)處理高手
- 跨境電商:速賣通搜索排名規(guī)則解析與SEO技術(shù)
- Photoshop-CorelDRAW 基礎(chǔ)培訓教程
- SPSS統(tǒng)計分析與應(yīng)用
- Flash CS6 動畫制作實戰(zhàn)從入門到精通
- 攝影師的后期課:Lightroom后期技法篇
- SolidWorks三維設(shè)計及工程圖速成