The AS3 Flickr API on Google Code (as3flickrlib) is a great tool for integrating Flickr into your Flex or Flash application.

But if you want to include the SWC in a Flex 3 or AIR project, you need to download the source code and recompile it as a Flex 3 Library. The SWC included in the zip file is compiled for Flex 2 and will generate a runtime error when you try to instantiate an instance of FlickrService.

Once you have the Flex 3 SWC in your project, using the actual Flickr API is pretty straightforward. As with all third-party Flickr apps, you first need to authenticate your application for a Flickr user.

Here’s a simplified version of the login process:

var flickr : FlickrService = new FlickrService (YOUR_FLICKR_API_KEY);
flickr.secret = YOUR_FLICKR_API_SECRET;

flickr.addEventListener (FlickrResultEvent.AUTH_GET_FROB, onGetFrob);

// starts the Flickr login process
flickr.auth.getFrob ();

private function onGetFrob (event : FlickrResultEvent) : void
{
    if (event.success)
    {
        var frob : String = event.data.frob as String;

        var authURL : String = flickr.getLoginURL (frob,
            AuthPerm.READ);

        navigateToURL (new URLRequest (authURL), "_blank");
    }
}


The authURL is the page on Flickr where you authenticate your application. Your app needs to be authenticated before you can retrieve an auth token:

flickr.addEventListener (FlickrResultEvent.AUTH_GET_TOKEN,
    onGetToken);

flickr.auth.getToken (frob);

private function onGetToken (event : FlickrResultEvent) : void
{
    if (event.success)
    {
        var authResult : AuthResult = event.data as AuthResult;

        flickr.token = authResult.token;
        flickr.permission = authResult.perms;
    }
}


Once you have an auth token, you should have access to the private information in the user’s account, and depending on the permission level, the ability to add, edit and delete photos and metadata.