Official Facebook Actionscript API released!
On March 31 Facebook developers announced that Adobe and Facebook are working together to provide official support for building rich social applications in Flash.

You can read the full Josh Elman’s announcement at this link.
The new ActionScript 3.0 Client Library for Facebook Platform API, fully supported by Facebook and Adobe, makes it easy to build applications that combine the strengths of the Flash Platform and Facebook Platform.
Flash is available on more than 98% of Internet-connected PCs, so people can immediately access the applications, content, and video that enable social interactions. The Facebook Platform is used by millions of people everyday to connect and share with the people in their lives.
You can read more about it at this page.
Obviously I started playing with this new API, and I followed the instructions in the official tutorial Create your first Facebook application with Flex, changing a couple of things to make it work as I wanted.
This is the source code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" backgroundColor="silver" backgroundImage="" applicationComplete="init()"> <mx:Script> <![CDATA[ import com.facebook.data.users.GetInfoData; import com.facebook.utils.FacebookSessionUtil; import com.facebook.data.users.FacebookUser; import com.facebook.data.users.GetInfoFieldValues; import com.facebook.commands.users.GetInfo; import com.facebook.net.FacebookCall; import com.facebook.events.FacebookEvent; import com.facebook.Facebook; private var fbook:Facebook; private var session:FacebookSessionUtil; private var user:FacebookUser; private function init():void{ session=new FacebookSessionUtil("83ccead57ece4086338470a75e13c5b1","1fff6abf608e90e70e1aad07798aa8e4",loaderInfo); session.addEventListener(FacebookEvent.CONNECT,onConnect); fbook=session.facebook; } private function onLogin():void{ this.removeChild(go_login); session.login(); } private function onConfirmLogin():void{ this.removeChild(loginbutton); session.validateLogin(); } private function onConnect(e:FacebookEvent):void{ var call:FacebookCall=fbook.post(new GetInfo([fbook.uid],[GetInfoFieldValues.ALL_VALUES])); call.addEventListener(FacebookEvent.COMPLETE,onGetInfo); } private function onGetInfo(e:FacebookEvent):void{ user=(e.data as GetInfoData).userCollection.getItemAt(0) as FacebookUser; title.text="Hello "+user.first_name+" "+user.last_name+" born on "+user.birthday; } ]]> </mx:Script> <mx:Label id="title" text="Facebook API test"/> <mx:Button id="go_login" label="Click here to login into Facebook" click="onLogin()"/> <mx:Button id="loginbutton" label="Click once logged into Facebook" click="onConfirmLogin()"/> </mx:Application> |
And this is the result:
As I am not a Flex maniac, I will fully explain (and improve) the script as soon as I’ll convert it to an AS3 class. Meanwhile I want you to focus on line 40 where I am getting information about the user.
The official page where you can get all the information about this process is this one.
Meanwhile, you can download the full source code with all needed libraries.
11 Responses to “Official Facebook Actionscript API released!”
Leave a Reply
Trackbacks
-
Official Facebook Actionscript API released - AS3 version : Emanuele Feronato on
April 12th, 2009 6:54 pm
[...] post contains a script made combining Official Facebook Actionscript API released! with Understanding Flash button component. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 [...]
- Citrus Engine released for free for learning
- My epic fail with ClickBank
- Get up to $100,000 for your next Flash game with Mochi GAME Developer Fund
- Create a dynamic content animated footer ad for your site in just 9 jQuery lines – 17 lines version
- Sell sitelocked version of your Flash games and even .fla sources to Free Online Games
- Protect your work from ActionScript code theft with SWF Protector
- Create a dynamic content animated footer ad for your site in just 9 jQuery lines
- Understanding Box2D’s one-way platforms, aka CLOUDS
- Triqui MochiAds Arcade plugin for WordPress upgraded to 1.2
- Box2D Flash game creation tutorial – part 2
- Create a Lightbox effect only with CSS - no javascript needed
- Flash game creation tutorial - part 1
- Create a Flash Racing Game Tutorial
- Flash game creation tutorial - part 2
- Make a Flash game like Flash Element Tower Defense - Part 2
- Flash game creation tutorial - part 3
- Triqui MochiAds Arcade plugin for WordPress official page
- Make a Flash game like Flash Element Tower Defense - Part 1
- Create a flash draw game like Line Rider or others - part 1
- Create a flash artillery game - step 1
- Flash game creation tutorial – part 5.2 (4.88/5)
- Create a flash artillery game – step 1 (4.79/5)
- Create a Flash Racing Game Tutorial (4.76/5)
- Create a survival horror game in Flash tutorial – part 1 (4.74/5)
- Create a flash artillery game – step 2 (4.74/5)
- Creation of a Flash arcade site using WordPress – step 2 (4.73/5)
- Flash game creation tutorial – part 1 (4.71/5)
- Flash game creation tutorial – part 2 (4.71/5)
- Create a flash draw game like Line Rider or others – part 1 (4.69/5)
- Creation of a platform game with Flash – step 2 (4.68/5)


(2 votes, average: 3.50 out of 5)



It doesn’t seem to be working for me. I login and have FB open in a new tab, then when I click the next button that validates my login the text still says “FaceBook API Test”.
Is anyone else experiencing this?
it’s the same for me… It does’nt work.
It works 4 me…
cool feature! sad i don’t have a facebook acc and also don’t plan to make one, but advertising there seems sweet!
I don’t get flex. Before you even get to the code, you have indented 3 times. Not my style.
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at prova/onGetInfo()[C:\Documents and Settings\Triqui\Desktop\provaflex\src\prova.mxml:39]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at com.facebook.net::FacebookCall/http://api.facebook.com/1.0/::handleResult()
at com.facebook.delegates::WebDelegate/handleResult()
at com.facebook.delegates::WebDelegate/onDataComplete()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
You should click the 2nd button (the one saying “Click once…”) only when you get “You may now close this window and return to the application.” message on your FB page.
Hi,
I just need a couple of info you may provide:
I have a site completly built with Flash, I’d like to create a section in my site where any user can see (by providing facebook username&pwd) all his facebook data (including photos, events, posts, etc…)
Do you think this is possible?
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at prova/onGetInfo()[C:\Documents and Settings\Triqui\Desktop\provaflex\src\prova.mxml:38]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at com.facebook.net::FacebookCall/http://api.facebook.com/1.0/::handleError()
at com.facebook.delegates::WebDelegate/handleResult()
at com.facebook.delegates::WebDelegate/onDataComplete()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
Is there a way to avoid the confirmed logged in page. Like checking to see if a session exist without having to open a login window and just returning to the web app?