Loading images from Facebook in Flash Builder
I'm doing a Facebook App where I'd like to pull out all the possible images from a user's album.
What I'm trying to do at the moment is a fql query so that i can find all the images that b开发者_运维知识库elong to that specific user. it goes something like that:
protected function loadFromFacebook(event:MouseEvent):void {
var fql:String = "select src_small from photo where owner = me()";
Facebook.fqlQuery(fql, handleGetPhotosResponse);
}
private function handleGetPhotosResponse(event:Object, fail:Object):void {
if (event != null){
facebookPhotos = new ArrayCollection(event as Array);
}
}
I store this images in an array collection but I don't know how to proceed after that. How can I load those images into, say, a Tile List or a Loader?
Any help would be much appreciated,
thanks
Assuming you are a TileList component named 'tList', you would do a 'for loop' on the arraycollection and create a new image, and add it to the TileList on each iteration.
// I am not sure if the array collection contains photo urls,
// but this is the general idea ...
// you may need to build the url with fb graph ...
for ( var i:uing = 0; i < facebookPhotos.length; i++ )
{
var img:Image = new Image();
img.load( facebookPhotos.getItemAt(i) ); // url here
tList.addChild( img );
}
you should do a handler function that receive a result object and a fail object. the result object is an array of fields that you requested with the fql.
protected function loadFromFacebook(event:MouseEvent):void {
var fql:String = "select src_small from photo where owner = me()";
Facebook.fqlQuery(fql, handleGetPhotosResponse);
}
protected function handleGetPhotosResponse(result:Object, fail:Object):void
{
photosList = new ArrayCollection();
var photo:Object;
for (var i:Object in result)
{
photo = new Object();
photo.imgSrc = result[i].src_small;
photosList.addItem(photo);
}
provider = photosList;
}
精彩评论