Getting Started with Teak in Flash

For backwards compatibility reasons our SDKs still reflect our previous name of 'Carrot'.

You can download the latest compiled version of the SDK here: Carrot.swc. You can also find the full source code on GitHub: github.com/GoCarrot/carrot-as3

Teak Initialization

In order to use Teak in Flash, you must pass in a unique user identifier. We suggest using the Facebook 'third_party_id' or email address.

var carrot:Carrot = new Carrot("your_teak_app_id",
                               "your_teak_api_key",
                               "unique_user_identifier");

Teak User Authentication

Authenticating a Teak user in Flash requires the Facebook user token for that user. This code snippet validates a Teak user.

carrot.validateUser("facebook_user_token_goes_here", function(status:String):void {
  switch(status) {
    // Everything is ok
    case Carrot.AUTHORIZED: break;

    // User has not allowed the 'publish_actions' permission
    case Carrot.READ_ONLY: break;

    // User has not authorized the Facebook app
    case Carrot.NOT_AUTHORIZED: break;
  }
});

Definining Social Triggers

Next you need to define the social triggers which will be sent to the Teak service to post stories.

// To post an achievement with the 'chicken' identifier:
carrot.postAchievement("chicken", function(status:String):void {
  if(status !== Carrot.OK) {
    // Handle the error
  }
});

// To post a high score:
carrot.postHighScore(42, function(status:String):void {
  if(status !== Carrot.OK) {
    // Handle the error
  }
});

// To post a social action with a dynamically created object instance:
carrot.postAction("push", "commit", null,{
  title: "Flash Test",
  image: "http://static.ak.fbcdn.net/rsrc.php/v2/y_/r/9myDd8iyu0B.gif",
  description: "Testing the Flash dynamic object generation"
}, function(status:String):void {
  if(status !== Carrot.OK) {
    // Handle the error
  }
});

SDK Documentation

Documentation for the Teak ActionScript 3 SDK can be found here: ActionScript 3 SDK Documentation