Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to display more than 25 images from a facebook album?

Status
Not open for further replies.

wraygun

Programmer
Dec 9, 2001
272
0
0
US
I have a flash application that is working great accept for displaying facebook albums, but there is a limit of 25 photos using the default settings. I've researched and it seems that you have to set the paging to a higher number and perhaps set the offset. I'm just not sure how to pass those values to facebook using ActionScript. Any help would be GREATLY appreciated. I'm including the code below:

Code:
import com.facebook.graph.Facebook;
import com.facebook.graph.controls.*;
import com.facebook.graph.core.*;
import com.facebook.graph.data.*;
import com.facebook.graph.net.*;
import com.facebook.graph.utils.*;
import flash.events.MouseEvent;
import com.adobe.serialization.json.*;
import flash.display.MovieClip;

var APP_ID:String = "248877778485757";
var SECRET_KEY:String = "b87cc3d878f524da6f813e61748c075a";

var albums:Array;
var aImages:Array;
aImages = new Array();
var aAlbumsButton:Array;

//Initialize Facebook library
Facebook.init(APP_ID, onInit);			
		
function onInit(result:Object, fail:Object):void 
{						
	login_mc.login_btn.buttonMode = true;
	login_mc.login_btn.addEventListener(MouseEvent.CLICK, onLoginClick);
}

//
function onLoginClick(e:MouseEvent):void
{
	root.makeFacebookScreen();
	
	if (Facebook.getSession() && Facebook.getSession().accessToken==null)
    {
       // t.text = "LOGGED OUT";
	   var opts:Object = {perms:"publish_stream, user_photos"};
		Facebook.login(onFacebookLogin, opts);
    }
    else
    {
      //  t.text = "LOGGED IN";
	  Facebook.logout(onFacebookLogout);
    }
}

//
function onFacebookLogout(success:Boolean):void 
{			
	var opts:Object = {perms:"publish_stream, user_photos"};
	Facebook.login(onFacebookLogin, opts);
}

//
function onFacebookLogin(result:Object, fail:Object):void 
{
	if (result) 
	{ 
		loggedIn();
	} 
	else 
	{
					
	}
}

//
function loggedIn():void
{
	//Facebook.api('/me/albums', onMyInfoLoaded);
	//Facebook.api('/235523383144855/photos', onMyInfoLoaded);
}

//
function makeAlbums():void
{
	Facebook.api('/me/albums', onMyAlbumsLoaded);
	
	removeChild(login_mc);	
}

//
function onMyAlbumsLoaded(result:Object,fail:Object):void 
{
	albums = result as Array;
	aAlbumsButton = new Array();
	
	for (var i:int = 0; i < albums.length; i++) 
	{
		var album:MovieClip = new FacebookAlbumButton();
		album.albumName = albums[i].name;
		album.albumID = albums[i].id;
		album.numPhotos = albums[i].count;
		album.id = i;
		album.y = 57 + i * album.height;
		addChild(album);
		aAlbumsButton[i] = album;
	}
	
	//load first album
	loadPhotos(0);
}

function loadPhotos(_id:Number):void
{
	removePhotos();
	
	for each(var a in aAlbumsButton )
	{
		a.isClicked = false;
		a.hover_mc.alpha = 0;
	}
	
	aAlbumsButton[_id].isClicked = true;
	aAlbumsButton[_id].hover_mc.alpha = 1;
	
	Facebook.api('/' +  albums[_id].id + '/photos', onMyPhotosLoaded);
}

/*login_mc.x = 1000;
onMyPhotosLoaded(null, null);*/
//
function onMyPhotosLoaded(result:Object,fail:Object):void 
{
	photos = result as Array;
	var xSpacing:int = 0;
	var ySpacing:int = 0;
	var rows:Number = 0;
	var cols:Number = 0;
	
	for (var i:int = 0; i < photos.length; i++) 
	{
		var photo:MovieClip = new FacebookThumb();
		photo.x = cols * photo.width + xSpacing;
		photo.y = rows * photo.height + ySpacing;
		photo.id = i;
		photo.thumbPath = photos[i].images[2].source;
		photo.photoPath = photos[i].source;
		aImages[i] = photo;
		images_mc.addChild(photo);

		cols ++;
		xSpacing += 15;
		
		//if( cols >= 5 )
		//{
			//cols = 0;
			//xSpacing = 0;
			//rows ++;
			//ySpacing += 15;
		//}
	}
	
	holder_cmp.source = images_mc;
	holder_cmp.verticalScrollPosition = 0;
	holder_cmp.horizontalScrollPosition = 0;
	

}

function removePhotos():void
{
	for each(var p in aImages )
		p.removeObject();
		
	aImages = [];
}

Thanks,
Wray

***You can't change your past, but you can change your future***
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top