Home  >  

Using the brand new Facebook ActionScript 3.0 library

Author photo
AddThis Social Bookmark Button
In the 5th article we will deal with Adobe's new Facebook ActionScript 3.0 library. It is a brand new product and it is still in beta, but it looks promising. In fact, it has been there for quite some time and was originally developed by Jason Christ. This time Adobe decided to support it and add features. The way the library works differs from the methods from the previous articles because it is completely based on ActionScript and does not use a PHP middle layer. In this article we will explore the library briefly and examine the basic features to get us started. The goal of this article is to create a simple swf file that will connect to Facebook.
series badge
Find the rest of this series on the series page.
The deal here is that we are making calls to the Facebook API directly from the SWF, with no PHP proxy. You might ask why we didn’t use it right away? The reason is that the PHP library we used before is a stable version and the library presented here is still in development so there are a lot of things to come. We will use this article to introduce the method and the future articles will rely completely on this library. In the previous article, we discussed the method with PHP and Flash to connect to Facebook and the knowledge we have from this article is important because we always need to know more then one way to get the results. After completing this series, we will be able to use the PHP library with Flash and the new Facebook AS3 Lib. This gives us a lot flexibility and confidence when working on Facebook projects.
As mentioned above, the library was developed by Jason Christ and the library was further developed by Adobe and the work is still in progress. The complete project repository can be found here (http://code.google.com/p/facebook-actionscript-api/). There you can track the latest changes in development, etc. There are also nice examples on this page so make sure you check it out.
In this article first we will:
1. Make a simple call to Facebook from the swf to make sure it works
2. Examine important functions and how they work in the ActionScript 3.0 library
3. Create a simple but useful example to demonstrate the usage of the library
This will be a lot of fun I promise!

Make a simple call to Facebook from the swf to make sure it works

First of all we need to know is that we do not need create a new Facebook application to run this and in order to run this. We will update the existing application from the previous example with the new library. The goal is to create a simple that connects to Facebook without problems. After that we should feel more comfortable to create more complex examples.
Find the application fla we worked on previously, on my side its called ria.fla.
Open the file and remove all code from it, we don’t need anything from the previous code because this is completely based on the Facebook AS3 library and there is no need to connect to PHP in order to communicate with the API. Also, remove all the components from the stage, for now we just need a blank swf for this sample.

article5_img1.png
In order to access the API, we need to download it, so go to http://code.google.com/p/facebook-actionscript-api/ and download the swc (for now we need only the swc and not the other downloads).

article5_img3.png
In the swc folder or the Flash CS3 installation (usually it’s C:\Program Files\Adobe\Adobe Flash CS3\en\Configuration\Components) create a folder called “FB” (the name of the folder is not important). Copy the swc into the folder.
Open the components panel in Flash.

article5_img3.png
Now click the reload the button:

article5_img4.png
You should see the Facebook Lib SWC in the components panel:

article5_img5.png
From the previous example, we have 2 layers in our sample. The upper one is for the ActionScript and the lower one for assets. Now drag the swc onto the stage and remove it immediately. This will send the swc to the library or our fla.

article5_img6.png
Now we are ready for the action! This is an important step because we are now able to work with the classes and methods inside the fla Remember now that this step is required for every fla that needs to use the new library. We will always have to drag the swc onto the stage for every new fla.

There is one thing we need to set up before we switch to code. We need to place one button onto the stage to better demonstrate the connection process between Facebook and the swf. Simply drag the button component somewhere on the stage and name it login_btn.

article5_img7.png
As we can see the label is changed to “Connect” but this step is not important.

Cool, let’s move on now to the code. Like in the previous examples, we will be using the the upper layer as the layer for our code.
Paste this code into the first frame:


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;
import flash.utils.*;

var fbook:Facebook;
var session:FacebookSessionUtil;
var user:FacebookUser;

session = new FacebookSessionUtil("YOUR_API_KEY", "YOUR_SECRET", loaderInfo);
session.addEventListener(FacebookEvent.CONNECT, onFacebookConnect, false, 0, true);

fbook = session.facebook;
fbook.login(true);

login_btn.addEventListener(MouseEvent.CLICK, connectToFB);
	
function connectToFB(e:Event):void {
 	
 	session.validateLogin();
 	
}

function onFacebookConnect(e:FacebookEvent):void{
 
 	trace("Is Facebook connected: " + fbook.is_connected);
 			
}
Run the example and click on the button. When the swf compiles and runs, we will see a browser window pop up and it will prompt us to log in if we are not already logged in.

article5_img8.png
After logging in, we see the following screen:

article5_img9.png
This means that we are logged in and that our swf can consume all the API resources we need for our application. Still we may be unsure if the application is logged in and may use the api. This is why we placed the button onto the stage. Now when we click on it, the session will be verified and the CONNECT event is fired.

article5_img10.png
Wow, that’s a big deal for us since we worked so hard to get this simple result.  So the first part of this article is finished. We did what was intended. The goal was to connect to Facebook and make a simple call.
Let’s walk quickly through the code:
We import the necessary classes:

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;
We create a variable for the Facebook instance:

var fbook:Facebook;
A utility for the Flash session is created:

var session:FacebookSessionUtil;
Now we initialize the session:

session = new FacebookSessionUtil("your_api_key", "your_secret”, loaderInfo);
The fbu variable holds the Facebook instance as a property:
	
fbook = session.facebook;
Then we add the listener to listen to the connect event:

session.addEventListener(FacebookEvent.CONNECT, onFacebookConnect, false, 0, true);
	
Finally we connect to it:

fbook.login(true);
Here is the callback function that is called when flash connects to facebook, neat!

function onFacebookConnect(e:FacebookEvent):void{
 
 	trace("Is Facebook connected: " + fbook.is_connected);
 			
}
Finally here is the code for the login button that checks the connectivity with the callback:


login_btn.addEventListener(MouseEvent.CLICK, connectToFB);
	
function connectToFB(e:Event):void {
 	
 	session.validateLogin();
 	
}

Examine important functions and how they work in the ActionScript 3.0 library

Since we made our first call from the swf to Facebook, we can now move on to explore other methods that the library provides provides. The syntax for calling the library is a bit different then by using the methods written in PHP but fortunately the names of all the methods are kept similar to the original so we will not confused. It’s important to note that all methods are kept as separate ActionScript files inside the com/facebook/commands folder and the methods are grouped in folders.
So, let's see how we can load the info about the user that is logged in. We will use the post() method and the class files that contain the methods.
At the top of the code, we will not change anything since everything is imported for this sample.
We need to go back our connection callback:

function onFacebookConnect(e:FacebookEvent):void{
 
 	trace("Is Facebook connected: " + fbook.is_connected);
 			
}
And add the following 2 lines of code:

function onFacebookConnect(e:FacebookEvent):void{
 
 	trace("Is Facebook connected: " + fbook.is_connected);
 
 	var call:FacebookCall = fbook.post(new GetInfo([fbook.uid],[GetInfoFieldValues.ALL_VALUES]));
 	call.addEventListener(FacebookEvent.COMPLETE,onGetInfo);
 		
}
Below the callback, we need to define a callback that will handle the result:

function onGetInfo(e:FacebookEvent):void{
 
 	var user = (e.data as GetInfoData).userCollection.getItemAt(0) as FacebookUser;
 	trace("Hello " + user.first_name + " " + user.last_name);
 
} 

article5_img11.png
Finally we got some more info about the users! As we can see there is the cool class called FacebookCall that handles calls to the Facebook api.

var call = fbook.post(new GetInfo([fbook.uid], [GetInfoFieldValues.ALL_VALUES]));
The post method receives the method instance like GetInfo and the additional parameters to load all values. Note that we pass the instances of classes inside the com.facebook.commands.* package. The whole package contains other packages and these are admin, application, users, feed, friends, fql, data, notifications, event etc.
So, we dont want get confused, so here is the complete code:

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;

var fbook:Facebook;
var session:FacebookSessionUtil;
var user:FacebookUser;

session = new FacebookSessionUtil("your_api_key","your_secret",loaderInfo);
session.addEventListener(FacebookEvent.CONNECT, onFacebookConnect, false, 0, true);

fbook = session.facebook;
fbook.login(true);

login_btn.addEventListener(MouseEvent.CLICK, connectToFB);
	
function connectToFB(e:Event):void {
 	
 	session.validateLogin();
 	
}

function onFacebookConnect(e:FacebookEvent):void{
 
 	var call:FacebookCall = fbook.post(new GetInfo([fbook.uid],[GetInfoFieldValues.ALL_VALUES]));
 	call.addEventListener(FacebookEvent.COMPLETE,onGetInfo);
 			
}

function onGetInfo(e:FacebookEvent):void{
 	var user = (e.data as GetInfoData).userCollection.getItemAt(0) as FacebookUser;
 	trace("Hello " + user.first_name + " " + user.last_name);
}

Create a simple but useful example to demonstrate the usage of the library

I promised it will be fun, right? Well until now there hasn't been much fun for us as the all the examples were bit boring. Well now we will make a switch and create a small application in AIR. The application will display the statuses of our friends so will easily be able to check the statuses of our friends. I like this app! Here is the final image:

article5_img14.png
The application itself will not be huge in size, there will be just one small window with the combo box for friends, profile image loader and the text field for the status.
First of all, what size of application should this be? For now, its best to be as small as possible, the application really does not do much at all so there is not need for huge screen consumption. In the fla we just played around, re-size it to 300 x 300. The button we placed on the stage should be left on the stage but it's best when it's centered on the top of the stage. Here is the image of the current compiled SWF:

article5_img12.png
Place a Combo box below the button and name it friendList_mc. Below that a UILoader named img_mc in the left and a simple TextField in the right named status_txt. Here is the image of the fla:

article5_img15.png
Now, based on the previous code we worked on, somehow we need to retrieve all friends. There is a package called import com.facebook.commands.friends.*; that has the magic we need. The complete call will look something like this:

var call:GetFriends = new GetFriends();
call.addEventListener(FacebookEvent.COMPLETE, onFriends);
fbook.post(call);
This needs to placed directly in the onFacebookConnect callback we previously defined.

function onFacebookConnect(e:FacebookEvent):void{
 
 var call:GetFriends = new GetFriends();
     call.addEventListener(FacebookEvent.COMPLETE, onFriends);
     fbook.post(call);
 			
}
We need to receive the result in this callback:

function onFriends(e:FacebookEvent):void{
 	
 	var friendsData = (e.data as GetFriendsData);
 	trace("Friends: " + friendsData.friends);
}
Finally, when compiled, we see the following result in the output window:

article5_img13.png
That’s the list of all our friends finally loaded into the SWF. Now it gets more and more exciting. The list that we have right now is a collection of objects of the specific type FacebookUser. Now you might say that we simply need to iterate through the objects to get the desired data? Like:

var friends = (e.data as GetFriendsData).friends;
	
var i;
var len = friends.length;
	
for(i = 0; i < len; i++){
 		
 	var user = friends.getItemAt(i) as FacebookUser;
 	trace(user.uid, user.first_name);
 		
}
This will work only for the user id. But in order to create an application that displays images and status messages, we need more information, and for that we need to call the GetInfo method again, this time with the array of ids of loade users. In one call, we will get the ALL information of ALL users.

var friends = (e.data as GetFriendsData).friends;
	
var i;
var len = friends.length;
var uids:Array = new Array();
	
for(i = 0; i < len; i++){
 		
 	var user = friends.getItemAt(i) as FacebookUser;
 	uids.push(user.uid);
 		
}
	
var call:FacebookCall = fbook.post(new GetInfo(uids, [GetInfoFieldValues.ALL_VALUES]));
call.addEventListener(FacebookEvent.COMPLETE, onDataRecieve);
    fbook.post(call);
As you can see, for we iterate though the array that was returned and create our own array only of user ids, just because the GetInfo() method accepts an array of user ids. Then, in the line

var call:FacebookCall = fbook.post(new GetInfo(uids, [GetInfoFieldValues.ALL_VALUES]));
we call the GetInfo method wanting the data of all users. We add the listener:

call.addEventListener(FacebookEvent.COMPLETE, onDataRecieve);
We call the method:

fbook.post(call);
The results will be received by the following callback function:

function onDataRecieve(e:FacebookEvent){
 	
 	var userData = ((e.data as GetInfoData).userCollection);
 	
 	var i;
 	var len = userData.length;
 
 	for(i = 0; i < len; i++){
  		
  		var user = userData.getItemAt(i);
  		var dataObj = new Object();
  		dataObj.label = user.first_name + " " + user.last_name;
  		dataObj.pic = user.pic_small;
  		dataObj.status = user.status.message;
  		friendList_mc.addItem(dataObj);
  		
  	}
 	
}
This is pretty simple. We iterate through the array of friends and retrieve all that is needed: name, pic and status. Then we add every item to the combo box on the stage. Finally, at the end we need the CHANGE listener that will switch and display the status and image of the user that was selected in the combo box.

friendList_mc.addEventListener(Event.CHANGE, changed);

function changed(e:Event){
 	
 	var img = e.currentTarget.selectedItem.pic;
 	var status = e.currentTarget.selectedItem.status;
 	
 	img_mc.source = img;
 	
 	status_txt.text = status;
 	
} 
And that's it, when you run the sample you will see that first the browser window will apprear where you have to login into your app, then after logging in, we need to press the Connect button in order to load the desired data.

article5_img16.png
I’ll leave it up to you how to create the AIR application out of this. I just used the command line compiler to create the .air file. There are lots of methods to create an AIR app out of your swf.
I hope you have enjoyed the series so far. In the next articles we will rely on the wonderful Facebook AS3 Lib because it fit more naturally into the development process of Facebook application development. The knowledge of PHP will come in handy later when working on own projects. In the next articles we will also go back to the “normal” Facebook applications that run inside the Facebook canvas. I wanted to use this article to introduce the lib and to introduce the a sample as a desktop application. Stay tuned for the next article! Bye.


Continue to Part 6 of this series, Component Architecture for Facebook Applications

To view the entire series please visit http://www.insideria.com/series-facebook-dev.html

Read more from Mirza Hatipovic. Mirza Hatipovic's Atom feed mirzahat on Twitter

Comments

53 Comments

Matthew said:

Hi, many thanks for writing this article. Will you be writing an article on how to use the brand new Facebook ActionScript 3.0 library to create an iFrame web application rather than a desktop one?

Many thanks again!

Matthew said:

Please ignore my last comment! sorry :( I presume you will explain iFrame usage soon

Octavi Masià said:

Hi Mirza.

I like very much your post. Thank you for the information. I'm following this tutorial and Flash don't run correctly and send me this error when the app makes the call to get the friends list:

1046: No se encontró el tipo o no es una constante en tiempo de compilación: GetFriends.

I'm sorry, the message is in spanish, can you understand?, can you help me?

Thank you

JK said:

Many thanks to Mirza Hatipovic
very clear explaination :)

========================================

Octavi Masià , error occure about this line right?

var friendsData = (e.data as GetFriendsData);

then you need GetFriendsData class

import com.facebook.data.friends.GetFriendsData;

Mirza Hatipovic said:

Thanks JK,

@Octavi

yes it seems like there are some classes missing :-)

Check the import statements...

Regards,
Mirza

Omar said:

Hello, Mirza,

Thank you for creating this series...it is very helpful.

I am getting this error:
1120: Access of undefined property e.

Omar said:

Hello, Mirza,

Thank you for creating this series...it is very helpful.

I am getting this error:
1120: Access of undefined property e.

Omar said:

(Omar Continued...)
Concerning this line:
var friends = (e.data as GetFriendsData).friends;

Is this because the variable "e" is only defined within the previous functions? How does this variable become defined?

Thank you for your help!
Omar

Rick said:

Isn't it bad practice to put your api and secret in the swf? Or is that ok now? I havent done facebook in a while as the last time I remember you had to set up a middle layer to keep your secret...uh secret :)

Mirza Hatipovic said:

Hello Rick

yes it is.

Instead we can use AMFPHP go load the secret and initiate the facebook session.

My new blog (http://riapearls.blogspot.com/) will cover such issues in more detail since I do not have the place to explain all in all.

Regards,
Mirza

Octavi Masià said:

Hello,

Thank you for your help, but i'm not know how to instal in flash the facebook component and the facbook Actionscript 03 libray. I have tried it in several ways and my script don't find the appropiate class. can someone help me? thank you.

Mirza Hatipovic said:

You can check my new blog http://riapearls.blogspot.com/ as it will cover the problems in depth :-)

Octavi Masià said:

Hi, everybody

I have superate my last problem and now the scrip give me the 1151 error in the line:

var user = friends.getItemAt(i) as FacebookUser;

Why is this? I only have cut and past the code tha i have read in this tutorial. Can you help me? Thank you very much!

Anonymous said:

Hi Octavi

can you post the whole method with all lines of code?

Octavi Masià said:

Yes this is the whole code.

var friends = (e.data as GetFriendsData).friends;

var i;
var len = friends.length;
var uids:Array = new Array();

for(i = 0; i
var user = friends.getItemAt(i) as FacebookUser;
uids.push(user.uid);

}

var call:FacebookCall = fbook.post(new GetInfo(uids, [GetInfoFieldValues.ALL_VALUES]));
call.addEventListener(FacebookEvent.COMPLETE, onDataRecieve);
fbook.post(call);

function onDataRecieve(e:FacebookEvent){

var userData = ((e.data as GetInfoData).userCollection);

var i;
var len = userData.length;

for(i = 0; i
var user = userData.getItemAt(i);
var dataObj = new Object();
dataObj.label = user.first_name + " " + user.last_name;
dataObj.pic = user.pic_small;
dataObj.status = user.status.message;
friendList_mc.addItem(dataObj);

}

}

Mirza said:

Hi Octavi

could you please send me the whole fla? :-)

Regards,
Mirza

Octavi Masià said:

Hi Mirza.

Thank you for your help. How can i send you the whole fla? Which is your E-mail?

Mirza said:

you can reach me via mirzahat@gmail.com

Guillermo Cabrera said:

Just wanted to thank you a lot for these tutorials. They are great and have been very helpful!

Bob said:

Octavi,

Thank you for the tutorial! I'm also having problems with this line:

var friends = (e.data as GetFriendsData).friends;

Please send the fla to :bob@engineempire.com

Thanks again!
Bob


nicolas florth said:

really cool tutorials ( and are specials because I can listen them in the same time with reading) I hope i will find hear something also for beginers, like me...this one it is a little bit to hard for me to understant it. ....really nice!

Lars Holen said:

Thanks a lot for the tutorials!

If your having problems with the:
var friends = (e.data as GetFriendsData).friends;
You might have missed importing the "GetFreindsData"
import com.facebook.data.friends.GetFriendsData;

Vadym said:

Good man, Thank you ! Great useful article.

Ada said:

hi! thnx alot for this documentation, is always grateful having people like Mirza.
Thanx alot again.

I did this tutorial, and i know where is the problem that Octavi has.

is in this line:

var call:FacebookCall = fbook.post(new GetInfo(uids, GetInfoFieldValues.ALL_VALUES]));

i think is wrong written, it must be like this:

var call:FacebookCall=fbook.post(new GetInfo([fbook.uid],[GetInfoFieldValues.ALL_VALUES]));

anyway i put the all code, it works great!!! is fantastic! i am super grateful about this! :) thanx again Mirza.


/////////////////////////////
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;
import com.facebook.commands.friends.*;
import com.facebook.data.friends.GetFriendsData;

import flash.utils.*;

var fbook:Facebook;
var session:FacebookSessionUtil;
var user:FacebookUser;

session=new FacebookSessionUtil("apikey","secreto",loaderInfo);
session.addEventListener(FacebookEvent.CONNECT, onFacebookConnect, false, 0, true);

fbook=session.facebook;
fbook.login(true);

login_btn.addEventListener(MouseEvent.CLICK, connectToFB);

function connectToFB(e:Event):void {

session.validateLogin();

}

function onFacebookConnect(e:FacebookEvent):void {

trace("Is Facebook connected: " + fbook.is_connected);

var call:FacebookCall=fbook.post(new GetInfo([fbook.uid],[GetInfoFieldValues.ALL_VALUES]));
call.addEventListener(FacebookEvent.COMPLETE,onGetInfo);

var call2:GetFriends = new GetFriends();
call2.addEventListener(FacebookEvent.COMPLETE, onFriends);
fbook.post(call2);


}

function onGetInfo(e:FacebookEvent):void {

var user = (e.data as GetInfoData).userCollection.getItemAt(0) as FacebookUser;
trace("Hello " + user.first_name + " " + user.last_name);

}

function onFriends(e:FacebookEvent):void{

var friendsData = (e.data as GetFriendsData);
trace("Friends: " + friendsData.friends);

var friends = (e.data as GetFriendsData).friends;

var i;
var len = friends.length;

for(i = 0; i
var user2 = friends.getItemAt(i) as FacebookUser;
trace(user2.uid, user2.first_name);

}


var call3:FacebookCall=fbook.post(new GetInfo([fbook.uid],[GetInfoFieldValues.ALL_VALUES]));
call3.addEventListener(FacebookEvent.COMPLETE, onDataRecieve);
fbook.post(call3);

}

function onDataRecieve(e:FacebookEvent){

var userData = ((e.data as GetInfoData).userCollection);

var i;
var len = userData.length;

for(i = 0; i
var user = userData.getItemAt(i);
var dataObj = new Object();
dataObj.label = user.first_name + " " + user.last_name;
dataObj.pic = user.pic_small;
dataObj.status = user.status.message;
friendList_mc.addItem(dataObj);

}

}

friendList_mc.addEventListener(Event.CHANGE, changed);

function changed(e:Event){

var img = e.currentTarget.selectedItem.pic;
var status = e.currentTarget.selectedItem.status;

img_mc.source = img;

status_txt.text = status;

}
/////////////////

Gregory Chatonsky said:

Hello Ada,

I use your code but in friendList_mc I just see my own name, not the names of my friends. Do you know why?

Thanks again Mirza for this tutorial.

Gregory Chatonsky said:

Hello Ada,

Thanks for the code but when I use it, friendList_mc just take my own name. How to put the complete listing of my firends?

Thanks again

MIrza said:

Hi Folks,

I really need to put a sample online for this article :-) please be patient :-)

Nandi Gunarsa said:

Hi Mirza,
Thanks for the post. It helps me a lot!
Keep up the good job!

Rgds,

video de laly gratuite said:

THANKS !!!
This is exactly what i tried to do !
Many thanks you saved my life. :D

bonus betclic said:

My girlfriend will love it ! :D

Frazko said:

does it always open a new window?? how can I avoid it? thanks

jord3t said:

I cannot get my session to connect on the live app. It only works when I test the movie in flash...

Is there any way to get a web session to work? (iframed application)

http://apps.facebook.com/jordetflash/

Carlos said:

Is there any way to validate the session without opening the new page in a new window? If not is it possible to open it in a popup? This would be so much cooler if it could validate silently in the background.

Carlos said:

I have seen flash applications on facebook which don't need to open another window. I thought maybe this was the answer to my problems...

http://facebook-actionscript-api.googlecode.com/svn/trunk/examples/ConnectDemo/src/ ...

but I simply could not get it to collaborate with your simple flash demo here the onGetInfo function would never get called. Any advise would be greatly appreciated. I just really dislike the page you have to close just to see your app, seems a real shame to me.

Mike said:

You rock.

Barnaby Byrne said:

Great tutorial!!

There are so many Flex tutorials on the internet, but Flex doesn't have the graphics capabilities (although it is great for designing apps with UI compnenets).

It is so refreshing to see a Flash tutorial on ths subject.

By the way, does the update to the Facebook_Flash_library (up to v3.2) impact this tutorial?

I not also that Adobe have split the library into two main parts Flash and Flex, whereas it used to be a single library. Why is this?

Best
Badger

Anonymous said:

Please follow me on Twitter for more updates on this topic:

http://twitter.com/mirzahat

MickyMike said:

Hi Mirza, I think it's an amazing series of tutorials!!

I want to ask you about a problem, that is giving to me a big headache:

there are some way to login without pop-up / new window, using AS3 API?

I see a lot apps in Facebook developed in AS/Flash, and none redirects me to a new window or pop-up...

Many Thanks!

earl said:

i'm stuck... right on the very first part. As i understand this, we don't need to make a FB App, so:

session = new FacebookSessionUtil("your_api_key","your_secret",loaderInfo);

remains the same without changing "your_api_key" and "your_secret" to their actual values... which i tried but still no luck.

Anyway, after testing the movie a new browser opens and verifies that i am logged into Facebook... but:

trace("Is Facebook connected: " + fbook.is_connected);

returns FALSE. Any ideas?

I tried the nest example.. the one to display your "Hello..." but i get a "null object reference" error in the onGetInfo function.

Need help please.

bala said:

Nice Article. I learned a lot from this. Please send complete fla to my email ID: balukorrapati@gmail.com


Thanks in advance

bala said:

Please send complete fla file as soon as possible. I need your help to resolve my issues. My email ID is: balukorrapati@gmail.com
Thanks in advance.

Colin Luzio said:

Thanks a lot for this! Mine was working completely fine. However, I tried it on a new computer and it doesn't seem to connect. I tried the first part and I was getting this message
Error opening URL 'http://api.facebook.com/restserver.php'
Is Facebook connected: false

What do I need to do to connect it? Many thanks

bala said:

Hello Ada/Mirza,

Thanks for the code but when I use it, friendList_mc just take my own name. How to put the complete listing of my firends?

If I use the code given in the Mirza description, I am getting the following error at var friends = (e.data as GetFriendsData).friends;
1120: Access of undefined property e.

I am importing the "GetFreindsData"

Please help me.

Thanks again

fuzzlly mclaren said:

Hi Mirza,

I'm sorry, I follow exactly your tutorial, everything else works fine except when I tried to load my friendlist...i've got this error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at TestApp_fla::MainTimeline/onDataRecieve()
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()

I assume there somewhere I dont understand when retrieving friends.
var userData = ((e.data as GetInfoData).userCollection);

Hell o said:

Nice post...

But what about returning visitors?
they have to re-approve the app?

I mean how to know whether an existing logged in user return to the page again? or refresh the page?

looking forward for your reply.

exootnet@yahoo.com

Nasir Ali Sher said:

Very useful tutorial. Really appreciate!

Can you tell us about resolving the following:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at TestApp_fla::MainTimeline/onDataRecieve()
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()

thanks

Nasir Ali Sher said:

Very useful tutorial. Really appreciate!

Can you tell us about resolving the following:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at TestApp_fla::MainTimeline/onDataRecieve()
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()

thanks

Sammie said:

How can turn off pop msg"You may now close this window and return to the application" every time I open my flash App within facebook ....?

Please ....cannot figure out this one ......

thanks

Sebastian said:

Hi Mirza,

Thanks for taking the time to write this tutorials and give back to the community.

I've tested your simple app and it works fine. Only weird thing, some statuses are displayed in the status_txt box, and some are not. They don't event trace out on the Output panel.

Any idea why?

Serban Balamaci said:

So, anybody has any ideea about not opening the popup window . It seems pretty stupid. I am on the Facebook site and another page opens saying that now I can close it and continue to my aplication, and in my application I need to verify the login again.

kanyal said:

Hi
Anybody get success using AS3 facebook library in facebook convas page either fb:iframe of fb:swf
also when i loaded swf in facebook convas a new tab or browser window opens similar as i was testing it on locally on my desktop system.
any body can refer good tutorial of app on facebook using this library.
i am new to facebook applications development by using this AS3 lib.
thanks in advance.
regards
kanyal

paul said:

I also had this method working but like someone mentioned above, I'm also getting this error now in the output window:

Error opening URL 'http://api.facebook.com/restserver.php'
Is Facebook connected: false

any ideas why?

Also for everyone asking about connecting without the pop up there's a tutorial that has a nicer method here:

http://www.stevenvh.be/blog/?p=57

manoj sahu said:

Hi,

excellence job!

but one problem here, when i tried to run application but in facebook , it says Error while loading page from abcds-application !

abcds-application is under construction. Please try again later.

whats wrong with me. api-key and secret key are fine, but still not getting the application works. why?


please reply

Leave a comment


Tag Cloud

iPad

What's your take on the iPad? (Putting aside the Flash/iPad flame war)

Answer

Latest Features

Recommended for You

@InsideRIA on Twitter

Archives

  • Or, visit our complete archive.  

About This Site

Welcome to the premiere community site for all things RIA sponsored by O'Reilly Media and Adobe Systems Incorporated.