Adobe AIR & GameCircle: Set Up Your App

Introduction

This page covers the steps for setting up the Adobe AIR ANE for GameCircle SDK 2.4. Initializing the GameCircle AIR ANE requires these steps:

  • Step 1: Include the Amazon GameCircle Library
  • Step 2: Initialize the GameCircle API

Step 1: Include the GameCircle Library

After you’ve downloaded the Amazon Mobile Apps SDK, use these instructions to include the Adobe native extension for the version of Flash you’re using

Instructions for Flash Professionals:

  1. Create a new “AIR x.x for Android” mobile project.
  2. On the File menu, click Publish Settings…
  3. In Publish Settings, the Script field should show “ActionScript 3.0”. Click the Wrench icon to edit the Script settings.
  4. Open the Library Path tab. Under SWC and ANE files or folders, click the Browse To Native Extension icon.
  5. Navigate to the Mobile Apps SDK files you downloaded, and locate the file com.amazon.extensions.GameCircle.ane. Select it and click OK. Click OK again to exit Script settings.
  6. In Publish Settings, the Target field should indicate the project type you created (“AIR x.x for Android”). Click the Wrench icon next to Targetto edit the Player settings.
  7. Open the Permissions tab. Select the check box Manually manage permissions and manifest additions for this app and click OK. Click OK again to exit Publish Settings.

Flash Builder 4.7:

  1. Create a new “AIR x.x for Android” mobile project.
  2. Go to Project Properties.
  3. In the left list, select ActionScript Build Path, and open the Native Extensions tab.
  4. Click the Add ANE… button, and browse to the file com.amazon.extensions.GameCircle.ane. Click OK to add it.
  5. In the Project Properties left list, select ActionScript Build Packaging > Packing > Android.
  6. Open the Native Extensions tab. Select the check box Package next to the extension you just added.

Step 2: Initialize the Amazon GameCircle API

The following steps gets the GameCircle AIR extension up and running. For an illustration, see the sample file example-src/GameCircleExample2.as.

  • Import the API classes
  • Initialize the API

Import the API classes

import com.amazon.nativeextensions.*;
import com.amazon.nativeextensions.events.*;
import com.amazon.nativeextensions.dispatchers.*;

Initialize the API

To initialize GameCircle, call the method GameCircle.create(). In response, one of the following events is fired:

  • GameCircleEvent.SERVICE_READY
  • GameCircleEvent.SERVICE_NOT_READY

Once create() has been called and SERVICE_READY is fired, an instance of the GameCircle API is available statically by accessing GameCircle.gameCircle. The system has been initialized and you are ready to start submitting scores and achievements to GameCircle.

Example:

// initialize with achievements, leaderboard, and whispersync support
 GameCircle.create().addServiceReadyListener(
   function(gameCircleEvent:GameCircleEvent):void {
      if (gameCircleEvent.type == GameCircleEvent.SERVICE_READY) {
         trace('Service ready  you can now call other GameCircle functions.');
      } else if (gameCircleEvent.type == GameCircleEvent.SERVICE_NOT_READY ){
         trace('Service start failed:' + gameCircleEvent.errorMessage);
 }});