My favorites | Sign in
Project Home Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
Documentation  
a quick overview of supported API methods and classes
Featured
Updated Oct 25, 2007 by tom.carden@gmail.com

Introduction

This project is intended to get you up and running with accessing Dopplr data from Flash 9 applications.

It is also a playground for me to experiment with finding the most elegant and aesthetically pleasing way to code such applications. Your input is welcome if you have opinions on how the code might be improved, or if you want to implement some of the Dopplr API methods I didn't get to yet.

Examples

Example code is in the com.dopplr.examples package. The simplest one is DopplrBasics but some of the others are better documented or more interesting.

These three examples should be self-contained:

  • DopplrBasics - loads all your fellow travellers (slow) and draws a block for each current city.
  • DopplrSparks loads all your fellow travellers (slow) and draws a spark line of activity for the most visited cities in the next 3 months.
  • DopplrArcs - loads all your fellow travellers (slow). Each traveller is an arc with radius corresponding to their distance from you and colour corresponding to the city they'll be in. Now is at 3 o'clock, time runs clockwise, the full circle represents 3 months.

These four examples also require you to download and include Modest Maps in your build path.

  • DopplrMapCircles draws great circle arcs for all your trips, attempting a pen stroke style to evoke flight rather than bombs.
  • DopplrFellowsMap draws icons for your fellow travellers on their current city.
  • DopplrAreas draws shapes corresponding to the amount of time you spend in each city you visit.
  • DopplrCityMap is like DopplrFellowsMap but draws a grid of icons for each city your fellow travellers are in (trying to mitigate the overlapping icons in fellows map, needs more work!).

Building / Compiling

I'm going to assume you're up and running with a development environment such as Flex Builder and that you've checked out the API classes and placed them in your build path already. If you're new to Actionscript 3 development, I can recommend Jeff Heer's excellent Flare Tutorial as good supplement to the official Adobe documentation about Flex Builder.

Getting a Token

First of all you'll need an AuthSub token from Dopplr testing with, if you're logged into Dopplr you can get one here.

You can worry about how to get a proper token later (there's example html and javascript here, just don't share your testing token or any swfs made with it in the meantime!

API Calls

First create an instance of the API class and add some listeners for statuses and errors:

var api:API = new API("your token goes here");
api.addEventListener(StatusEvent.STATUS, onStatus);
api.addEventListener(ErrorEvent.ERROR, onError);

onStatus and onError should be implemented in your class.

Next call one of the following methods with a callback that expects the appropriate response.

// call one of these functions first:
api.loadAuthenticatedUser(onUserLoaded);
api.loadTravellerInfo('mattb', onUserLoaded);
api.loadFellowTravellers(onUsersLoaded);

The onUserLoaded callback will receive a Traveller, the onUsersLoaded callback will receive an array of Travellers:

public function onUserLoaded(user:Traveller):void
{
    // do something with the traveller here
}

public function onUsersLoaded(users:Array):void
{
    // loop through the travellers here
}

Once you have a traveller or an array of them, you can call some additional functions. Since a request for one traveller doesn't include trip info, you can call api.loadTravellerTrips with a Traveller to fill in their trips.

When you load the authenticated user's fellow travellers they don't come with trips or home/current city info. To load the former, use api.loadFellowTravellersTrips, and to load the latter use api.loadFellowTravellersInfo.

API Classes

The Model class (which belongs to the API class) attempts to keep a list of unique Traveller, Trip and City instances and hashes of those objects by their unique identifiers.

Each Traveller has an array of trips, each Trip has a city (destination) and a departure. Cities also store their Dopplr colour in the rgb variable.

Each city also keeps an array of all the trips it knows about.

Powered by Google Project Hosting