Carousel image for flickr- inside view

This page reveals the secrets of integration to flickr service from the the image carousel application in Flash Lite 2.0.

Program searches for images on the flickr site by the given tag and places first eight of them into the carousel for viewing.

Flickr is very popular and very open. There is an open API that allows application developers to manipulate flickr content. API provides a lot of functionality and not so easy to use as is. Good thing that some people have created wrappers for many popular programming languages. Since you are reading that document you are interested in learning more about action script support. There are links to several implementations. I like most the one from kelvinluck.com. This is a set of classes with the access to all methods of flickr api and easy to understand example.

Making modifications to invoke search was not too difficult. The basic idea is very simple: initiate search by tag and provide the callback functions for notification when search complete.

import com.kelvinluck.flickr.example.UserRecentPhotosLite;

// Code that starts loading of images from Flickr
function loadFromFlickr() {
	onImagesInfoLoaded = function (l:Array) {
		itemimage = new Array();
		imageamount = 8;
		for (i=0; i < imageamount; i++) {
			itemimage[i] = l[i];
		}
		num = imageamount;
		createFrames(num);
		loadAll();
		keyboardSetup();
	};
	UserRecentPhotosLite.mainPrint(onImagesInfoLoaded);
}

The main portion of the code above is definition of callback function onImagesInfoLoaded. It is activated if all data from Flickr has been recived. As soon as images info arrived we can continue execution by creating empty fremes (placeholders) and setting up softkeys.

// mainPring from UserRecentPhotosLite
public static function mainPrint( fprt:Function):Void
{
	trace( "main" );
	var u:UserRecentPhotosLite = new UserRecentPhotosLite(_root, fprt);
}

Create new object instance and pass the callback function name to it.

/**
* Function: UserRecentPhotosLite
* Constructor
**/
function UserRecentPhotosLite(target:MovieClip, callBackMe:Function)
{
	feedBack = callBackMe;
	
	// initalise logging to Flash's output window
	LogWrapper.getInstance().init();
	LogWrapper.getInstance().addTracePublisher();
	
	_target= target;
	var _flickr:Flickr = Flickr.getFlickr();
	_flickr.apiKey = apiKey;
	var _flickrResponseListener:FlickrResponseListener = new FlickrResponseListener();
	_flickrResponseListener.setSuppressOutput(true);
	//_flickrResponseListener.onPeopleGetPublicPhotos = Delegate.create(this, onPeopleGetPublicPhotos);
	_flickrResponseListener.onPhotosSearch = Delegate.create(this, onPhotosList);
	//_flickr.peopleGetPublicPhotos(userNsid, null, 16, 1 );
	_flickr.photosSearchMy( "flower", 16, 1 );
}

Object constructor make all nessasary initialization and gets the job done by calling _flickr.photosSearchMy providing "flower" as a search tag.