AS2 GamesChart API Implementation - Flash Develop

From GamesChart

Jump to: navigation, search

Implement the API using flash Develop by following 8 simple steps:

File:gameschartsite-downloadAPI.png

Contents

Step 1 - Download the 'GamesChart Developer Pack'


This folder contains all the files you need in order to implement the GamesChart API.

File:flashdevelop-MainasAS2.gif

Step 2 - Open Main.as


Launch Flash Develop and open the ‘Main.as’ file of your game.

File:flashdevelop-classpathAS2.gif

Step 3 - Add Classpath


  1. Select Project > Properties, then select the Classpaths tab.
  2. Click on Add Classpath and browse to the GamesChartAPI-AS2 folder (GamesChartDeveloperPack\GamesChart API\GamesChartAPI-AS2).
  3. Select the folder and click OK.
  4. Click OK to close the Project Properties window.

File:flashdeveloper-addswftolibraryAS2.gif

Step 4 - Add 'GamesChartAPI-AS2' to library


  1. Left click the GamesChartAPI-AS2 node in the Project panel to view contents.
  2. Right click the GamesChartAPI-AS2.swf and select Add To Library.
  3. The GamesChart API is now added to your project.

File:gameschartsite-getgameid.png

Step 5 - Get your Unique Game ID


To get a Unique Game ID you must create an instance of the game on GamesChart.com.

Go to your Developer Console and select Add Game, then enter your game name and select Create.

File:flashdevelop-setupfunctionAS2.gif

Step 6 - Call the GamesChart 'setup' function


For the GamesChart API to work you must call the static GamesChart function: setup.

This function should be run at the very start of your game.

Insert your Unique Game ID into the setup function.


Example Setup Function

GamesChart.setup("bc055fe4f21c9617e6463b7c0ecc7101");

File:flashdevelop-publishgameAS2.png

Step 7 - Publish .swf


Now publish your game..

You should ensure in Project Properties (Project > Properties) that you select Flash Player version 8 or higher.

The GamesChart tab will automatically display in the top right hand corner of your game.

You can adjust the tab position by adding the following static function. Replace x and y with the desired tab co-ordinates.

GamesChart.showTab(x, y);

File:Gameschartsite-uploadgame.png

Step 8 - Upload Game


Return to the GamesChart website to complete the Upload Game procedure.

The Upload Game pages will provide information on how to complete this process.

The implementation is now complete!

If you are getting error messages then refer to the Error Messages section below.

See the Learn More section below for information on customizing the behaviour of the API.

Error Messages


AS2 Error Messages include:

  • noInterface:"[GC-API] ERROR! Please call gc.setup() first." More Info
  • alreadyDefinedInterface:"[GC-API] ERROR! Can only call setup once!" More Info
  • noContainerMC:"[GC-API] ERROR! You must supply a container to hold GamesChart!" More Info
  • noGameIDHash:"[GC-API] ERROR! You must supply the game ID key associated with this game!" More Info


Learn More!


GamesChart static functions can be used to control the behaviour of the API.

For example, you can:

  • Hide the GamesChart button when required
  • Display the GamesChart button when required
  • Adjust the position of the GamesChart button
  • Open the GamesChart window on an event


Tell me more about Static Functions

Personal tools