ActionScript setup

This guide will walk you through a step-by-step process to set up a basic Action Script project using the Gamedonia Backend Platform.

Gamedonia provides two different SDKs for ActionScript, one suited for Web development and the other one for Mobile. Both come with the basic features of the Gamedonia API (User management, Data storage, Facebook integration...) but each has some specific features:

Web SDK

  • Kongregate purchases
  • Facebook purchases

Mobile SDK

  • Push notifications
  • Silent login with UDID
  • Google Play / iTunes Connect purchases

Get the Gamedonia ActionScript SDK

Log in to Gamedonia and get the SDK at the Download Area. We recommend checking the SDK version, as we're regularly updating them.

Integrate game with backend

Web SDK Flash Builder project setup

  1. Unzip the file GamedoniaSDK_ActionScript_v1_x_x.zip.

  2. Start creating a new ActionScript/Flex project using the Flash Builder wizard.

  3. Setup the project name and location and click on Next.

  4. In the Build Paths step we are going to add the Gamedonia AS3 SWC library. Click the Add SWC... button shown in the next image:

  5. Locate the Gamedonia SDK file you uncompressed previously (GamedoniaSDK_AS_web.swc) and select it.

  6. Click on Finish and your project will be created.

Mobile SDK Flash Builder project setup

  1. Unzip the file GamedoniaSDK_ActionScript_v1_x_x.zip.

  2. Start creating a new ActionScript/Flex Mobile project using the Flash Builder wizard.

  3. Setup the project name and location and click Next.

  4. In the Build Paths step we are going to add the Gamedonia AS3 SWC library. Click the Add SWC... button shown in the next image:

  5. Locate the Gamedonia SDK file you uncompressed previously (GamedoniaSDK_AS_mob.swc) and select it.

  6. Now click on the Native Extensions tab and then Add Folder... We will add some extensions to handle some of the services (for instance, GDSocial to communicate with Facebook).

  7. The .ane files are located in the same folder where you found the SWC. Select the folder to import all the extensions at once.

  8. Click on Finish and your project will be created.

  9. Now right click on the project main folder and select Properties. Go to Flex Build Packaging and select your target platform. Then open the Native Extensions tab and mark all .ane's. After that, click on Apply and OK.

  10. Check that the AIR SDK version you are using (in this case it's 16.0) corresponds to the one on your file descriptor's header (your_project_name-app.xml):

    <?xml version="1.0" encoding="utf-8" standalone="no"?>
    <application xmlns="http://ns.adobe.com/air/application/16.0">
    	
    • To check your AIR SDK version, you can use one of the methods described here
    • For a guide on how to overlay a specific AIR SDK version on a Flex SDK, follow this guide.
  11. Now right click on the project folder and select Properties. Go to Flex Compiler > Additional compiler arguments and add this argument: -swf-version=27. This argument specifies the SWF file format version of the output SWF file. It needs to be equivalent to the AIR SDK version defined in the application descriptor (see chart below).

    The compiler argument and the AIR SDK version have a correspondence but they are not the same number. This chart can help:

    swf-version AIR SDK version
    24 13.0
    25 14.0
    26 15.0
    27 16.0
    28 17.0
  12. You have successfully configured the Gamedonia SDK for ActionScript!

Run on Android device

Right click on the project folder, select properties and choose Flex Build Packaging -> Google Android. Then click on the Digital Signature tab. Here you need to set a Certificate (.p12 file) to sign the application. You can create one by clicking on the Create... button and giving the certificate a name and a password.

Next you need to create a run configuration for an Android device. You can do it by right clicking the project folder and selecting Run as... > Run configurations. Select the options shown in the next image, give the run configuration a name and connect an Android Device on your USB port. Then click on Run.

The app should now run on your Android device! You can find the .apk in the bin-debug folder.

Run on iOS device

Right click on the project folder, select properties and choose Flex Build Packaging > Apple iOS. Then click on the Digital Signature tab.
Here you have to fill these two fields:

  • Certificate: Your Apple iOS Developer certificate in .p12 format.
  • Provisioning file: Your provisioning profile certificate in .mobileprovision format.

If you don't know how to obtain these Apple certificates, check this guide.

Next you need to create a run configuration for an iOS device. You can do it by right clicking the project folder and selecting Run as... > Run configurations.
Select the options shown in the next image, give the run configuration a name and connect an iOS Device on your USB port. Then click on Run.

A pop-up will appear with the following instructions:

Open iTunes, go to File > Add to library... , search the .ipa file in the bin-debug folder of your project and install it through iTunes. Click on Apply/Syncronize and you should see your app installed on your iOS device!

Create a Game in Gamedonia

We need to create a game in the Gamedonia Dashboard to be able to continue. The Dashboard is the developer tool that will allow you to manage all the related modules of the game. Now let's see how we can create a Game.

  1. Click the Add New backend button.

  2. Write the name of your new backend, select the platform and press Save when ready, your game will be created inmediately and will be ready to start communicating with your game client.

Initializing the SDK Client

To enable the GamedoniaSDK in your app you need to complete the initialization process with a simple call to a function.

  1. Import the main Gamedonia class in your code like this:

    import com.gamedonia.sdk.Gamedonia;

    Remember to import any other classes you need from the Gamedonia SDK.
     

  2. Locate your application starting point. We need a piece of code that runs once on startup.

  3. Call initialize through the Gamedonia singleton. This function takes four arguments. The game Api Key, game Secret, Api Server Url and the Api Version.

    Example initialization call

    Gamedonia.initialize("your_game_api_key","your_game_secret","http://api.gamedonia.com","v1");
    
  4. Replace your_game_api_key and your_game_secret with the values in the Game Management > Information page.

When developing your app for the App Store or Google Play or whatever public market you should use the normal key that will respect all the security policies defined in your app. Use this as your default.

The master key lets you override permissions and access all entities and collections in the game, ignoring their Read/Write permissions.

User Authentication

Now your app is ready to perform calls to Gamedonia Backend!

You may be wondering what could be the first thing to do now that you have access to your own game backend. Why not create a User and log him in? You will need a logged in user (valid Gamedonia session) to invoke most of the Gamedonia API calls.

Create your first user

We will start with an easy example, where we create a user with email credentials ( email and password ). Here's how to create a user with ActionScript.

Login a user

The call to log in a user is the one that gets you a session token and, with it, the authentication to perform the rest of the API calls of the Gamedonia API. The credentials must be the ones of a created user at the Users collection. See how to log in a user with ActionScript.