Increase Engagement with Social Leaderboards in AS3 Games

Datetime:2016-08-23 02:55:02         Topic: ActionScript          Share        Original >>
Here to See The Original Article!!!

App42AS3 SDKnow supports integration of Facebook leaderboard in AS3 games which helps you in making your game more engaging with a higher rate of conversion. To demonstrate this feature, we have released a newer version of our Snake War sample.This sample contains integration of Facebook login , Facebook friend leader-board and sharing score on Facebook wall.

To get started with this sample, below mentioned are the steps to proceed:

  1. Registerwith App42 platform.
  2. Create your App once you are on Quick Start page, and get your API Key and Secret Key.
  3. If you are already registered,loginto AppHQ console and get your API Key and Secret Key from App Manager –>Application Keys section.
  4. Create a  new game in AppHQ console by clicking  Add Game  button in the Game panel (AppHQ Left Menu/Business Service Manager/Game Service/Game).
  5. Download Snake War sample from our Git repo
  6. Unzip downloaded file on your system and copy the social leader-board folder in your xamp/htdocs folder.
  7. Initialize App42 SDK by putting the APIKey & SecretKey in file (SocialLeaderBoard/src/ and add your game name which you have created in the above steps.
  8. Save your project and run as a web application.

Design Details

Below are the API calls from App42 AS3 SDK that has been used for social engagement feature in this sample:

Initialize App42 AS3 SDK

var scoreBoardService:ScoreBoardService = App42API.buildScoreBoardService();
var socialService:SocialService = App42API.buildSocialService();
var gameName:String = "<YOUR_GAME/LEVEL_NAME>"; // Created in Step #4

Saving your Facebook user score

leaderBoard Increase Engagement with Social Leaderboards in AS3 Games
var userName:String = "<User_Name>"; // In sample, we have used user's facebook user id  as a user name.
var gameName:String = "<Your_Game/Level_Name>" // Created in Step #4
var gameScore:int = 1000;
 scoreBoardService.saveUserScore(gameName,userName,gameScore, new callback());
//Callback Class
public class callback implements App42CallBack
	public function onException(app42Exception:App42Exception):void
		trace("App42Exception is : " + app42Exception);
	public function onSuccess(response:Object):void
		var game:Game = Game(res);
		for(var i:int=0;i<game.getScoreList().length;i++)
		     trace("User Name is : " + Score(game.getScoreList()[i]).getUserName());
		     trace("Value is : " + Score(game.getScoreList()[i]).getValue());
		     trace("Score Id is : " + Score(game.getScoreList()[i]).getScoreId());

Sharing score on Facebook wall :

var accessToken:String = "<FACEBOOK_ACCESS_TOKEN>"; // From login we have saved the access token and passed it here.
var link:String = "<LINK_TO_BE_POSTED>";
var message:String = "<MESSAGE_TO_BE_POSTED>";
var pictureUrl:String = "<PIC_URL_TO_BE_POSTED>"; // in sample we have added our game logo image
var fileName:String = "<FILE_NAME-TO_BO_POSTED>"; // It could be any name of the posted file
var description:String = "<FILE_DESCRIPTION_TO_BE_POSTED>"; // For sample concerned (Beat my score)
socialService.facebookLinkPostWithCustomThumbnail(accessToken, link, message, pictureUrl, fileName, description,new callback());
//Callback Class
public class callback implements App42CallBack
	public function onException(excption:App42Exception):void
		trace("Exception Message");
	public function onSuccess(response:Object):void
		var app42Response:App42Response = App42Response(response);
		trace("app42Response is : " + app42Response);

If you have any questions or need any further assistance to integrate this, please feel free to write us at


Put your ads here, just $200 per month.