I'm trying to switch my app over from using the entire stream to using a
specific set of photos. The bulk of my code requires a PagedPhotoSet,
but I don't seem to be able to get that using the following code:
//----------------------------------------------------SEARCH FOR
SETS
//Search for photo SETS using user id
private function findUserSets():void{
this._fs.photosets.getList(USERID);
this._fs.addEventListener(FlickrResultEvent.PHOTOSETS_GET_LIST, setsFound);
}
//event handler for PHOTOSETS_GET_LIST
private function setsFound(e:FlickrResultEvent):void {
trace("setsFound");
var sets:Array = e.data.photoSets as Array;
var firstSet:PhotoSet = sets[0] as PhotoSet;
this._photoList = firstSet.photos as PagedPhotoList;
//************problem? the photos property seems to have no
length***************
//store total number of photos in list for looping later
this._numPhotos = firstSet.photoCount;
//add tiles to target
this.addThumbs();
}
I believe this is the flow of events for working with PhotoSets and the
photos contained therein:
-get frob
-get list of user's sets by passing user ID to search
-choose desired set from returned list
-get photos for that set
-work with returned PhotoSet, which finally contains the actual Photo
objects
Here's the code to get through the above steps (please excuse redundant
code, as this was patched together):
public function Gallery() {
//Allow flickr domain, so we can do all the bitmapdata stuff
Security.allowDomain(FLICKR_URL);
Security.loadPolicyFile(CROSSDOMAIN_URL);
//Initialise FlikrService with the API key
this._fs = new FlickrService(API);
this._fs.secret = SECRET;
//Get that frob!
this._fs.auth.getFrob();
//Listen for the response of the event - Error listeners can
be put for monitoring errors
this._fs.addEventListener(FlickrResultEvent.AUTH_GET_FROB,
gotFrob, false, 0, true);
}
//---------------------------------GOT FROB
//event handler for AUTH_GET_FROB
private function gotFrob(evt:FlickrResultEvent):void {
if (evt.success) {
//trace("frob acquired");
findUserSets();
}
}
//----------------------------------------------------SEARCH FOR
SETS
//Search for photo SETS using user id
private function findUserSets():void{
this._fs.photosets.getList(USERID);
this._fs.addEventListener(FlickrResultEvent.PHOTOSETS_GET_LIST, setsFound);
}
//event handler for PHOTOSETS_GET_LIST
private function setsFound(e:FlickrResultEvent):void {
//trace("setsFound");
var sets:Array = e.data.photoSets as Array;
var firstSet:PhotoSet = sets[0] as PhotoSet;
//get list of Photos in set
this._fs.photosets.getPhotos(firstSet.id);
this._fs.addEventListener(FlickrResultEvent.PHOTOSETS_GET_PHOTOS,
gotPhotos);
}
//event handler for PHOTOSETS_GET_PHOTOS
private function gotPhotos(e:FlickrResultEvent):void {
//trace("gotPhotos");
//store total number of photos in list for looping later
this._photoList = e.data.photoSet as PhotoSet;
this._numPhotos = this._photoList.photos.length;
//DO SOMETHING COOL
}