Adobe Releases AS3 Facebook API

Adobe just released the “ActionScript 3.0 Client Library for Facebook Platform API”, which is a wordy name for a pretty straightforward AS3 Facebook API we’ve been working on for the past few weeks.

The library is an updated version of a library originally developed by Jason Crist. We’ve been working with Adobe, Facebook, and Jason to extend it to support all of the Facebook APIs (Canvas, Connect, and Desktop), and to clean up some of the code. That’s not to imply that Jason’s original work wasn’t great, there’s just a limit to how much you can do for free as one guy on an open source project.

The end result is an open source AS3 API that mirrors the documented Facebook API almost exactly. We’ve also added a few helper methods, and some samples to make it easier to get started.

You can get more info here, or grab the library from google code here.

Grant Skinner

The "g" in gskinner. Also the "skinner".

@gskinner

32 Comments

  1. I am having problems with the webcam example. I didn’t change any of the file and I am getting this everytime I run it:

    TypeError: Error #1009: Cannot access a property or method of a null object

    reference.

    at WebCamUploader/WebCamUploader::sendUserToAllow()[C:\DropBox\My

    Dropbox\Jeff\APIs\facebook_flash_api\facebook_library_v3.0_source\facebook_source\

    Any ideas??

  2. It seems to be failing here for me:

    protected function sendUserToAllow(p_event:MouseEvent):void {

    fb.login(true);

    }

    And yes, I did enter my API Key and Secret Key… 🙂

  3. Great news for flash developers who want to leverage the engagement of the facebook platform. At sprout we are doing some cool campaigns and were a part of the AS 3.0 library facebook beta. Already have a working app. check it out here sproutinc.com/socialmedia

  4. Could someone recommend any tutorials using the AS3 Facebook Platform API with the Flash IDE? Seems all the available examples are Flex based. Thanks in advance…

  5. a lot of the demos I have tried won’t work

  6. This is the webcam app:

    http://apps.facebook.com/webcam_uploader/

    It is still throwing that same error. Any ideas?

  7. Jeff & all Facebook API users. I have just posted updated demo source for all 3 demos to the Google code svn. You can browse the latest source here: http://code.google.com/p/facebook-actionscript-api/source/browse/#svn/trunk/examples.

  8. How do I start a session in an iframe so i dont have to do the login in an external window?

    Thx!

  9. “How do I start a session in an iframe so i dont have to do the login in an external window?

    Thx!”

    I’d like to know how to do this too. 😉

    Thanks from spain!

  10. Just took a quick look at the web cam, where you pass the session_key as a var into the swf.

    and establich the connection.

    Ill try it out tonight.

    Thanks

  11. Is there a cut down version suited to ports. I emailed my question in more detail to your ‘info’ address.

  12. Hello Grant,

    Can you tell the guy that made the ConnectJSdemo to fix it? (Or better, you fix it :P)

    It seems that it’s not working.

    Please have a look at this thread:

    http://groups.google.com/group/facebook-actionscript-api/browse_thread/thread/f6ef61562e004485

    Thanks in advance

  13. Andy Roberts May 7, 2009 at 8:48am

    I would really like to know how the Ben and Jerry’s approach works. The only example I’ve gotten to work forces the app to open a separate browser window, make the user login and close this window, and then click on a button in the app to trigger fb validation – after login is supposedly complete. This is very clunky compared to how it’s done in the Ben and Jerry’s example.

  14. The API itself is very well structured and really easy to get into.

    I do however think it’s lacking a lot of info on how to effectively integrate it with Facebook Connect. I count myself as a fairly weathered actionscripter and it took me an unecessary amount of time to get it working seamlessly with the ‘opaque’ facebook connect javascript.

    I think the whole package would benefit from a few actual hands on examples. The ones on the adobe page that had one of yours just didn’t really cut it when you were looking for a seamless application.

    Either way, in the end everything works perfectly and my comment is more of a ‘it could save time for a lot of people’ than a complaint 😉

    /sekasi

  15. Is anyone aware of any examples of using PublishUserAction, etc. (such as creating and working with Templates)? I’ve searched in vain for any AS-related discussions on the subject.

    Great library, by the way!

    –ChrisH

  16. sekasi,

    You say “I count myself as a fairly weathered actionscripter and it took me an unecessary amount of time to get it working seamlessly with the ‘opaque’ facebook connect javascript.”, to help others who face the same issues, why not offer your code as an example of how to use connect.

    Neil

  17. Daniel Wilday June 11, 2009 at 12:38pm

    Grant,

    I create AS3 Flash Apps in Flash Builder. From my tests it seems that this Library only works if you are using the Flex framework. Can you confirm this so I can stop running in circles?

    Dan W

  18. hi,guys,

    im a very recent flash devloper, portuguese living in London, and im Despered, i can’t understand faceBook API and get it to work , maybe because im really tired, well may be.

    I just need to create something that in my point of view should be very simple, that is a share button in flash AS2 that when released share a title and a text to faceBook. SORRY to ASK this, you are probably very busy, but could you please help? something very simple like:

    var TITLE:String;

    var TEXT:String;

    Share. onRelease = function () {

    input_title = TITLE;

    input_text = TITLE;

    getURL (“http://www.facebook.com/share.php?u=www.mywebsite.com”, “_blank”, “post”);

    }

    i dont want it to get the title from my index.html.

    IN ADVANCE THANK YOU VERY VERY MUCH.

    i always will be able to you in case that you need me, what i truly doubt.

    Jose.

  19. If you see a blank page and its not working. One of the reason could also be that –

    your Facebook App is not configured correctly; the ‘Connect URL’ wasn’t right.

    Go through the FB Connect tutorials on the FB wiki. Take notes of the FB App settings, esp the ‘Connect’ tab. Your ‘Connect URL’ needs to point to the directory where your .swf file is located on the server.

  20. 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?

    (I’m a very good flash developer but I know very little about facebook…)

  21. I think Adobe should think twice before allowing you to develop the api because your example source codes don’t work. If you are paid to develop the api, then you must provide better documentation and better source codes. can’t believe I spent the whole day and can’t make your examples work

  22. Firefox version 3.6 won’t make flash facebook apps work. I updated my Firefox and since then my apps are not working. I tested the same apps on Firefox version 3.5.8 and things work

    Sincerely,

  23. @ny amen to you brother/sister. I just spent 3 hrs trying to connect from a local SWF export.

    Firefox 3.6 (MacOS 10.5.8) did open up a window, but never actually navigated to the Facebook login page, and hence would not authenticate me.

    Changed the default browser to Safari and that works. Thanks for your post I was going nuts.

  24. Hi, Gskinner

    I apologize about what I wrote above. The problem was not your source code, but ff3.6; Your example code work on all browsers but ff3.6;

    Sincerely,

  25. When I am intending to record a video on facebook with my webcam I continuously receiving a report saying error fail to connect to the server. can this problem rectified

  26. Webcam and FB. Authori.

    The FB login.php has changed Apr.2010 to the Graph API. so the Link in the Web: must be any from

    // navigateToURL(new URLRequest(“http://www.facebook.com/login.php?api_key=”+API_KEY));

    .e.g. the webcamUploader.as

    changed into like:

    // navigateToURL(new URLRequest(“https://graph.facebook.com/oauth/authorize?client_id=XXX&redirect_uri=http://apps.facebook.com/YourCallbackfolder/scope=user_photos,user_videos,publish_stream,email,user_groups?api_key=XXX”));

    }

    than the webcam app is initializing the “allow”. BUT.the webcam is stilll not showing the webcamimage.

    anyone any ideas.

    i would appreciating to connect me via facebook:

    http://www.facebook.com/profile.php?id=100001200157853&

    if you have a solution or not. in this case we should communicate.

    and if anyone has a working webcam app. pls let me know.

    Kind Regards

    Maximilian /euka lyptus/

  27. Hi, i’ve a question about integrating the new like button in as3, this is possible?

  28. I can’t find any documentation on how to “Like” a page in AS3. Has anyone found a solution?

  29. Hi,

    I’d like to know if you have some sample code to tag a photo before using the uploadPhoto method. We’re using flex 4 and the Facebook Flex 3.4 API.

    Heres what we have do far:

    public function set setImage(_image:BitmapData):void

    {

    var _enc:JPEGEncoder= new JPEGEncoder( 80 );

    var _snapshotBA:ByteArray = _enc.encode( _image );

    m_image=_snapshotBA;

    }

    private function uploadImage( _event:Event ):void

    {

    //Creates the photo and attaches the image to it

    var _uploadPhoto:UploadPhoto = new UploadPhoto(m_image);

    //Uploads the Photo

    var _uploadPhotoPost:UploadPhoto = m_fbook.post(_uploadPhoto) as UploadPhoto;

    //Creates an event listener on the Uploading process, that fires once the photo is uploaded successfully.

    _uploadPhotoPost.addEventListener(FacebookEvent.COMPLETE, onUploadPhotoComplete,false,0,true);

    }

  30. I am using the api with Air 2.0 and ‘Air html’. Login, permission and upload works fine. But I need to log out the user. I tried auth.ExpireSession and auth.RevokeAuthorization but the user is still logged. I even deleted the cookies. But no success.

    Did anyone has any idea how to logout the user?

  31. Is the face book like button possible in flash? cant find documentation.

  32. hi,

    is is possible to post ads on facebooks and make call to facebook ad api from as3 facebook api

Leave a Reply

Your email address will not be published. Required fields are marked *