Now you need to do some setting-up. Luckily, GamerSafe has all the functions available for you to use right away. All of the functions are listed and documented below,
so have a quick look through this page and you'll soon learn all you need. To make it even easier, here is a quick overview of the functions that you'll use the most:

Example code and API Overview

The first thing I want to talk about is the GamerSafe Status bar. This little bar is a great help! It will sit in the bottom left hand corner of your game, and pop up when
your user want's to use it. You can hide it completley by using the API functions, but if your user leaves it alone, it will hide away in the corner itself.

The status bar looks like this:

By default, the status bar will appear in your game. It will shrink itself down to the "Auto-hide" state when not in use, and pop back up to the normal state when the user moves
their mouse over it.

The first method - the conventional way using addEventListener will require your function to accept 1 argument, like so:function myFunction(e:Event):void
The second method does not require this argument, therefor the function should be declared like so:function myFunction():void
Please note that with the second method of adding an event listener, you can only assign ONE event to be fired. Use addEventListener if you require to fire more than one function.

Look and Feel:

The function setStyle will allow you to specify the default theme for every component displayed by GamerSafe. Please see the setStyle documentation.
You can configure the Achievement popup with the setAchievementStyle() function.

Some functions take an optional "configuration" parameter. Examples are showShop(), showAchievements(),
or showPopup(). If provided, this should be an Object with one or more special variables set. These variables
determine the look and feel of that specific component. Not all of the following values are acceptable for every component.

[static][read-only]
The api variable allows you to access your instance of GamerSafe from anywhere in your code.
After constructing your GamerSafe object, one of the easiest ways of accessing the API functionality
is by using GamerSafe.api.

The api variable allows you to access your instance of GamerSafe from anywhere in your code.
After constructing your GamerSafe object, one of the easiest ways of accessing the API functionality
is by using GamerSafe.api.
You can access all of the functions that you need by using GamerSafe.api, and because it
is static, it can be accessed anywhere from within your code.
You MUST initiate one instance of the GamerSafe class using the code provided from the website
before trying to access this api variable. If the GamerSafe object has not been initiated then
this variable will return null.

Returns true if the API has been initialised by the constructor. If this returns false, you need to
call new GamerSafe(stage) - passing the stage or root displayobject in.

Implementation public static function get apiLoaded():Boolean

applicationDomain

property

applicationDomain:ApplicationDomain [read-only]Implementation public function get applicationDomain():ApplicationDomain

autoLogin

property

autoLogin:Boolean [read-write]

If this is set to FALSE before the session is started,
the user will not be automatically logged in to their GamerSafe account.
We don't reccomend this, but it may be needed in some cases.

Implementation public function get autoLogin():Boolean public function set autoLogin(value:Boolean):void

See also

showLogin

countryCode

property

countryCode:String [read-only]

Retrieves the country code of the user playing the game, based on their IP4 address.
This function can return unusual things (like "??" or "" or " ") for some special
IP addresses. However, the code will always be two characters or less. Typical codes
look like "US" or "CA" (for United States and Canada, respectively).

Implementation public function get countryCode():String

facebookFriends

property

facebookFriends:Array [read-only]

This function returns an array of Objects listing the user's Facebook friends.
The array is populated once the onFacebookGotFriends event fires.
The array is full of objects, each with two String properties,
name and id.
Pass the IDs to either facebookWallPost() in the target parameter, or to
facebookGetPicture().

Implementation public function get facebookFriends():Array

facebookLocalUser

property

facebookLocalUser:Object [read-only]

This function returns an object containing information about the currently logged
in user. This object is populated once the onFacebookGotLocalUser event fires.
The contents of this object can vary widely due to Facebook privacy settings.

Implementation public function get facebookLocalUser():Object

facebookLocalUserId

property

facebookLocalUserId:int [read-only]

Returns the Facebook user ID for the current user.

Implementation public function get facebookLocalUserId():int

facebookLoggedIn

property

facebookLoggedIn:Boolean [read-only]

This function will let you know if the user is currently logged in to Facebook.

Implementation public function get facebookLoggedIn():Boolean

failed

property

failed:Boolean [read-only]

Returns true if something went wrong.

Implementation public function get failed():Boolean

FAQUrl

property

FAQUrl:String [read-only]

The FAQ URL is the most up-to-date GamerSafe user FAQ.
This URL will change between executions of your game so you must not hard-code it.

Implementation public function get FAQUrl():String

gameAuthCode

property

gameAuthCode:String [read-only]

Used with PlayerIO QuickConnect. Returns this game's passcode.

Implementation public function get gameAuthCode():String

gamerGold

property

gamerGold:uint [read-only]

This variable will return the current user's balance, in GamerGold.

Implementation public function get gamerGold():uint

gamerPoints

property

gamerPoints:uint [read-only]

This variable will return the current user's balance, in GamerPoints.

Implementation public function get gamerPoints():uint

gamerTestMode

property

gamerTestMode:Boolean [read-only]

This variable will return whether the logged-in user is a test account.
Test accounts can only log in while your game is set to "inactive" on the
GamerSafe website.

Implementation public function get gamerTestMode():Boolean

gamerXP

property

gamerXP:uint [read-only]

This variable will return the XP of the current user. "XP" is a sum of the
total GamerPoints ever achieved by this user.

Implementation public function get gamerXP():uint

highScore

property

highScore:Number [read-write]

Gets the current highscore as a number.

Implementation public function get highScore():Number public function set highScore(value:Number):void

iconUrl

property

iconUrl:String [read-only]

The iconURL is a location where your game's achievement and item icons
can be accessed from the web. To find the complete URL, append the item
or achievement's "iconName" variable to the iconUrl.
Note that this URL will change between executions of your game so you must
not hard-code it into your application.

Implementation public function get iconUrl():String

inSession

property

inSession:Boolean [read-only]

inSession will be set to "True" if you are currently
connected to GamerSafe. Connecting happens automatically
once the API has been downloaded.
You can listen for the event begin_session or
begin_session_failed to create actions which you
would like to be executed as soon as the session has started.

Implementation public function get inSession():Boolean

See also

onBeginSessiononBeginSessionFailed

inUse

property

inUse:Boolean [read-only]

You can use the inUse variable to determine whether your player is currently
using the GamerSafe components or not.
Your game should be paused if "inUse" is true during gameplay, as it means that
the user is doing things with our components.
Also, if your game hides the mouse, when inUse is true, you should show the mouse
cursor.
You can detect when inUse changes by listening on any of the following events:

EVT_INUSE_CHANGED

EVT_INUSE_STARTED

EVT_INUSE_ENDED

Function assigned event triggers:

onUseChanged

onUseStarted

onUseEnded

Implementation public function get inUse():Boolean

isGamerGoldPurchaseDisabled

property

isGamerGoldPurchaseDisabled:Boolean [read-only]

Returns true if the current portal the game is on disallows GamerGold purchases.
In this case, items that cost Gamer Gold will not be displayed in the shop. However,
if they were purchased by the user on some other portal site, they will still work.

Implementation public function get isGamerGoldPurchaseDisabled():Boolean

items

property

items:Array [read-only]

Get a list of all items.
Returns an array of Items. These should be typecasted to "Object",
and then the following properties will be accessible:

Retrieve information about the last item-consumption attempt by the user during this session.
The returned Object contains at least these members:
itemID (the ID of the item that was attempted to be consumed)
desiredQuantityToConsume (how many you tried to consume)
actualQuantityConsumed (how many were REALLY consumed; can be lower than desired quantity!)

Implementation public function get latestItemConsumptionInfo():Object

latestItemPurchaseInfo

property

latestItemPurchaseInfo:Object [read-only]

Retrieve information about the last item-purchase attempt by the user during this session.
The returned Object contains at least the following four members:
itemID (the ID of the item being purchased),
priceID (the ID of the Price object the user bought the item at),
isSuccessful (true if purchase actually happened),
reason (set to some English string if purchase was not successful)

Implementation public function get latestItemPurchaseInfo():Object

latestOtherGameProfile

property

latestOtherGameProfile:Object [read-only]

The results of the latest call to requestOtherGameProfile.
See that function for an example of usage.

Implementation public function get latestOtherGameProfile():Object

latestScoreboardEntries

property

latestScoreboardEntries:Object [read-only]

You should get object when the EVT_SCOREBOARD_ENTRIES_RECEIVED event fires.
null will be returned if the GamerSafe API isn't loaded, or if you haven't requested the scoreboard entries.
The returned object will have the following structure:
var scoreboard_id:int;
var daily:Array; // Array of scores for today
var weekly:Array; // Array of scores for this week
var monthly:Array; // Array of scores for this month
var all:Array; // All scores, ever.

Implementation public function get latestScoreboardEntries():Object

levelVaultLastCreatedLevelID

property

levelVaultLastCreatedLevelID:uint [read-only]

Returns the internal level ID of the last level created in the LV by this client.

Implementation public function get levelVaultLastCreatedLevelID():uint

levelVaultLastEditedLevelID

property

levelVaultLastEditedLevelID:uint [read-only]Implementation public function get levelVaultLastEditedLevelID():uint

levelVaultLastError

property

levelVaultLastError:String [read-only]

The last error that the level vault interface has encountered.

Implementation public function get levelVaultLastError():String

levelVaultLastSelectedLevelsReceipt

property

levelVaultLastSelectedLevelsReceipt:int [read-only]Implementation public function get levelVaultLastSelectedLevelsReceipt():int

levelVaultReady

property

levelVaultReady:Boolean [read-only]

The level vault becomes ready shortly before you get the beginSession event.
If this is false, check for an error.

Implementation public function get levelVaultReady():Boolean

levelVaultShareCookie

property

levelVaultShareCookie:String [read-only]Implementation public function get levelVaultShareCookie():String

loaded

property

loaded:Boolean [read-only]

The loaded variable will return 'true' when the API has
succesfully been downloaded from the GamerSafe servers

Implementation public function get loaded():Boolean

loggedIn

property

loggedIn:Boolean [read-only]

The loggedIn variable will be set to TRUE after
a user has succesfully logged in.
You can listen for the events login and login_failed

Implementation public function get loggedIn():Boolean

See also

onLoginonLoginFailed

partner

property

partner:String [write-only]

Partner/sponsor stuff

Implementation public function set partner(value:String):void

paymentUrl

property

paymentUrl:String [read-only]

The payment URL is the web page to show users that want to add GamerGold to their account.
This URL will change between executions of your game so you must not hard-code it.

Implementation public function get paymentUrl():String

savedGame

property

savedGame:String [read-write]

Returns the current saved game, or an empty string if you've never set the
savedGame. The savedGame is a per-game, per-player string that automatically
serializes itself whenever the player is logged in. It has no predetermined
format; you can make up whatever format you want to save your game data in.

Implementation public function get savedGame():String public function set savedGame(value:String):void

signupUrl

property

signupUrl:String [read-only]

The signup URL is the web page to show users that want to sign up for GamerSafe.
This URL will change between executions of your game so you must not hard-code it.

Implementation public function get signupUrl():String

startingTime

property

startingTime:Date [read-only]

Retrieves the time the game connected to GamerSafe, in GMT. This is the time the
server reported, not the time the client marked. Thus, it can be more accurate than
the client time because players could randomly change their computer's clock. Returns
null if not yet connected to GamerSafe!

Implementation public function get startingTime():Date

status

property

status:String [read-only]

The status variable allows you to determine the current
status of the API. This can be any of the following:

Loading

Downloading

Ready

Failed

Implementation public function get status():String

twitterLoggedIn

property

twitterLoggedIn:Boolean [read-only]

This function will let you know if the user is currently logged in to Twitter.

Implementation public function get twitterLoggedIn():Boolean

twitterUser

property

twitterUser:XML [read-only]

Returns the Twitter user data for the current user.

Implementation public function get twitterUser():XML

unregisteredName

property

unregisteredName:String [read-only]

Gets the unregistered name. You should call the requestUnregisteredName function, then get this value
from within the event listener for the event EVT_UNREGISTERED_NAME

Implementation public function get unregisteredName():String

userAuthKey

property

userAuthKey:String [read-only]

Used with PlayerIO QuickConnect. Returns the logged in user's authentication key.

Implementation public function get userAuthKey():String

username

property

username:String [read-only]

Use this to access the current user's username.

Implementation public function get username():String

wantsNewsletter

property

wantsNewsletter:Boolean [read-write]

The "wantsNewsletter" boolean is intended to be connected to a check-box widget in your
game. The idea is that you show a checkbox labeled "Yes! Sign me up for your newsletter!"
or something similar. If users click this box, you can set wantsNewsletter to true. If they
unclick it, set wantsNewsletter to false. This value is automatically saved as soon as a
user is logged in.
Please note that there is no way to RETRIEVE the actual email addresses of people who have
signed up for your "newsletter", except by talking to administrators. You must make prior
arrangements with the GamerSafe administrative staff in order to use this feature; we will then
organize a method to give you the mailing list or to send out email on your behalf. Among other
things, we will need to be able to verify that your game implements the checkbox in a non-abusive
way. The checkbox must default to OFF, not ON, meaning that users must "opt in" to your newsletter,
not "opt out" of it.
The "newsletter" can actually be any sort of mailing list you want -- just as long as you
explain to users when and how often they will receive email from you.

Implementation public function get wantsNewsletter():Boolean public function set wantsNewsletter(value:Boolean):void

GamerSafe constructor.
Important Note: You must only create one instance of the GamerSafe object in your project.
If you try to create a second instance, it will not initiate properly and a message will be
logged to the output console (trace())

Parameters

parent:* — It is imperative that the parent object that you pass to the GamerSafe constructor
is either Sprite, MovieClip or Stage.

passcode:String (default = null) — The game's passcode, available on the website.

hashseed:String (default = null) — The game's hashseed, also available on the website.

isAir:Boolean (default = false) — If you want to build the game for Adobe AIR, set this to true.

Method detail

bestowAchievement

()

method

public function bestowAchievement(achievementId:uint):Boolean

bestowAchievement is the function that you call to give an
achievement to the currently logged in user.
Your Achievement IDs can be obtained from the GamerSafe, along
with auto-generated code to help you.
You can call this function as soon as the GamerSafe session has begun. You
do NOT need to wait for the user to log in before bestowing achievements.

Parameters

achievementId:uint

Returns

Boolean

bestowFreeItem

()

method

public function bestowFreeItem(itemID:int):Boolean

bestowFreeItem will instantly and silently grant the user an item.
The item must be free -- that is, it must not cost any GamerPoints or
GamerGold. You typically use this to give out free items for winning the
game or achieving certain goals.
You can call this function as soon as the GamerSafe session has begun. You
do NOT need to wait for the user to log in before bestowing free items.

Parameters

itemID:int

Returns

Boolean

closeItemInterface

()

method

public function closeItemInterface():void

Closes the currently open 'buy item' interface.

closeScoreboard

()

method

public function closeScoreboard():void

Close the open scoreboard dialog

closeShop

()

method

public function closeShop():void

Manually hides the Shop interface. Normally, a user will do this
by clicking the "X" in the upper right corner.

configureView

()

method

public function configureView(config:Object):void

Establishes a default configuration for all the GS UI windows, see the main class
comments for the various values that can be set. Useful for smaller size games.

Parameters

config:Object

consumeItem

()

method

public function consumeItem(itemId:int, numToConsume:int):void

Attempts to "consume" a consumable item. This may or may not work...
you have to wait for the event to come back from the server to see. (The event is
"consumption_completed", you can catch that event or assign a function to
onConsumptionCompleted to intercept this event.)
When you intercept the event, you can call getLatestItemConsumptionInfo() to see
the results of how it went.
Please do NOT assume that this function automatically works, because there are
special conditions where the player could abuse this. For instance, if the player
plays your game on two computers at the same time, using the same GamerSafe account,
they might consume items in one version of the game and try to consume them in the
other as well! To keep players from scamming you (and us), you must wait for the event
to see how many consumptions actually happened.
Consumable items can have any number of "consumptions" on a single item. For instance,
a player could buy one item that is "5 Plays of a MiniGame". They can then consume this
item five times to play the mini-game 5 times.
You shouldn't use this for very small purchases, because the bookkeeping is very tedious
to the user (and the server!). For instance, users will see EVERY item purchase in their
purchase logs... so if you sell e.g. "1 Bullet for 1 GamerPoint", and make the player buy
5000 bullets, the poor player will have hundreds of pages of purchase logs to wade through!
This will not make them happy. Here's the rule of thumb: you should expect a player not to
want to buy more than four or five copies of any given consumable item. (Some crazy players
might buy more, but for most players, that should be enough.)

Parameters

itemId:int

numToConsume:int

disable

()

method

public function disable():void

Disable the API. This will stop gamersafe from processing any requests. Use enable() to re-enable the API.

enable

()

method

public function enable():void

Re-enables the API if it's been disabled using the disable() function.

Use this function to configure an attachment for facebookWallPost. This
is where you should put content about your game, not in the text of the wall post.
See the facebook
developer wiki for more info.

Parameters

name:String — The top line of your attachment, bold and blue and linked to the URI.
ex: {Name} just got {Achievement} in {Game}!

caption:String (default = null) — The second line of your attachment, typically the name of the game.

link:String (default = null) — A URI that is linked on the name of your attachment.

picture:String (default = null) — A URI that usually leads to an image file. Can also link to a video or SWF file.

facebookConnect

()

method

public function facebookConnect(requireLogin:Boolean = false):void

Use this function to pop up the GamerSafe Facebook Login screen in a new window.
Note that the user may already be logged in to Facebook when the GamerSafe session
starts. Use the onFacebookConnected handler to receive notification that they've
finished the login process.

Relevant Events:

onFacebookConnected

onFacebookLoginFailed

onFacebookGotLocalUser

onFacebookGotFriends

onFacebookWallPostSuccess

onFacebookWallPostFailed

Parameters

requireLogin:Boolean (default = false) — If set to true, users are required to register for gamersafe in order to use Facebook.

facebookGetPicture

()

method

public function facebookGetPicture(uid:String = "me"):URLRequest

This function returns an URLRequest that will load the profile picture of a
Facebook user (from the facebookFriends array).

This function lets you write to a Facebook wall as the logged in user.
You should always prompt the user before calling this function, and you
must not pre-populate the "text" field for them.
The onFacebookWallPostSuccess or the onFacebookWallPostFailed
event will fire shortly after you call this function.

This function is useful with the LevelVault, so that you can fetch the avatars of
account creators. Send it an array of account IDs, and it will return an array
of all usernames fetched to date, keyed to their IDs. Since the avatars have to be
fetched from the server, you should also listen for the EVT_AVATAR_FETCHED event
and call this function again to get the new names.

Parameters

uids:Array (default = null) — GamerSafe user IDs to look for.

Returns

Array

fetchUsernames

()

method

public function fetchUsernames(uids:Array = null):Array

This function is useful with the LevelVault, so that you can fetch the names of
account creators. Send it an array of account IDs, and it will return an array
of all usernames fetched to date, keyed to their IDs. Since the usernames have to be
fetched from the server, you should also listen for the EVT_USERNAME_FETCHED event
and call this function again to get the new names.

Parameters

uids:Array (default = null) — GamerSafe user IDs to look for.

Returns

Array

flashBar

()

method

public function flashBar():void

Makes the GamerSafe status bar flash.

getAchievementSkin

()

method

public function getAchievementSkin():Object

Returns the current Achievement popup style settings.

Returns

Object

getAvatar

()

method

public function getAvatar(uid:uint):String

This function is like fetchAvatars except it will never call the server.
It only takes one ID as a parameter and returns the avatar for that ID if it is already
cached from a call to fetchAvatars.

Parameters

uid:uint

Returns

String

getConsumptionsAvailable

()

method

public function getConsumptionsAvailable(itemId:int):int

Retrieves the number of "consume"s a given item has. This value is
meaningless if the item isn't set to be consumable!

Parameters

itemId:int

Returns

int

getItemById

()

method

public function getItemById(item_id:int):Object

Get a specific item from it's item ID. This function will return either an item object (see items), or
null. It will return null if the API is not yet loaded, or if the object cannot be found. You should always
check to see if the item returned is null before attempting to access any of it's variables or functions or
your code may throw an error.

Parameters

item_id:int

Returns

Object

getSavedGame

()

method

public function getSavedGame(idx:int = 0):String

Returns a saved game. Currently only two are available.getSavedGame(0) would be the same as the savedGame getter.getSavedGame(1) is the new secondary saved game.
Anything else will return null.

Parameters

idx:int (default = 0)

Returns

String

getSkin

()

method

public function getSkin():Object

Returns the current global style settings.

Returns

Object

getUsername

()

method

public function getUsername(uid:uint):String

This function is like fetchUsernames except it will never call the server.
It only takes one ID as a parameter and returns the username for that ID if it is already
cached from a call to fetchUsernames.

Parameters

uid:uint

Returns

String

hasAchievement

()

method

public function hasAchievement(achievementId:int):Boolean

You can use this function to check wether the user has had an achievement
bestowed to them or not.

Parameters

achievementId:int — The ID of the achievement to check. This can be found
on the GamerSafe website.

Returns

Boolean

See also

showAchievementsbestowAchievementachievements

hasItem

()

method

public function hasItem(itemId:int):Boolean

You can use this function to check wether the user owns the item queried.
If the user does not own the item, FALSE will be returned, if they have
1 or more of the item, TRUE will be returned.

Parameters

itemId:int — The ID of the item to check. This can be found
on the GamerSafe website.

Returns

Boolean

See also

showShopitems

hideFriendsList

()

method

public function hideFriendsList():void

Hides the friends list control when you're done with it.

hideInterface

()

method

public function hideInterface():void

Completely hides the GamerSafe UI and all of its children.

hidePublisher

()

method

public function hidePublisher():void

Hides the publisher control when you're done with it.

hideShopButton

()

method

public function hideShopButton(disable:Boolean = true):void

hideShopButton() will allow you to disappear the shop button on the status bar.
You can still show and hide the shop through your code, this just keeps them from
opening it through ours.

Parameters

disable:Boolean (default = true)

hideStatusBar

()

method

public function hideStatusBar():void

hideStatusBar() will completley remove the status bar from the screen.
You may want to call this function whilst the user is playing on a level
in your game, however it is unintrusive, so it may be desirable to display
it during gameplay in some cases.

hideTwitterPublisher

()

method

public function hideTwitterPublisher():void

Hides the publisher control when you're done with it.

levelVaultCreateLevel

()

method

public function levelVaultCreateLevel(levelData:*):Boolean

This function will create a new Level in the LV. It's suggested you use ByteArrays for binary data.
Otherwise, your object will be packed into a ByteArray with the ByteArray.writeObject function.

Parameters

levelData:* — the object you want to save in the LV.

Returns

Boolean

levelVaultCreateLevelFromBytes

()

method

public function levelVaultCreateLevelFromBytes(levelData:ByteArray):Boolean

This function will create a new Level in the LV.

Parameters

levelData:ByteArray — the ByteArray you want to save in the LV.

Returns

Boolean

levelVaultCreateLevelFromObject

()

method

public function levelVaultCreateLevelFromObject(level:Object):Boolean

This function will create a new Level in the LV.

Parameters

level:Object — this object will be converted to a ByteArray with the ByteArray.writeObject function.

This function will attempt to copy the information in the given LV object into a new instance of the type you pass.
This is just a convenience function. It will return an object of the type you pass, but it may be Null.

This will use the ByteArray.readObject() function to create an object from the level data you pass it.
If you call it without a level parameter, or with null, it will attempt to cast the level data from
the most recently selected level.

This function allows you to log a specified user in. It can be used to make
your own Log-in interface, or it can be called with hardcoded credentials
to log in a test account for First Impressions/FGL use.

Parameters

username:String

password:String

rememberMe:Boolean (default = false)

logout

()

method

public function logout():void

"Logging out" causes the system to stop trying to re-log-in the
user. This "logs them out of GamerSafe". However, this doesn't
log the user out of YOUR GAME (so if you call GamerSafe functions,
they will still work). To emulate the latter behavior, stop calling
GamerSafe functions after the user to logs out.

purchaseItem

()

method

public function purchaseItem(itemID:int, priceID:int = 0):Boolean

purchaseItem will cause a given item to be purchased. Listen for the
'item_purchase' and 'item_purchase_failed' events to know when the purchase
completes.
The user must be logged in.
You can provide a price ID, but since currently all items
have a single price, this is redundant -- just pass 0 to use the default
(and only) price of the item.

Shows the purchase item popup. Can be used to prompt a user to buy a specific
item.

Parameters

itemId:int

priceID:int (default = 0)

requestOtherGameProfile

()

method

public function requestOtherGameProfile(otherGamePasscode:String):void

This is an advanced feature for developers who are writing sequels to an earlier GamerSafe
game they have already launched. It lets the game obtain information about how well the player
did in that earlier game. Among other things, you can obtain a list of Item IDs and Achievement IDs
for items and achievements the player earned. (Those IDs correspond to constants in the GamerSafe.as
header file for your earlier game. You'll want to copy-n-paste those earlier game constants into your
new game somewhere so you can refer to the IDs by name, instead of by weird numbers.)
When the request completes, an EVT_OTHER_GAME_PROFILE_RECEIVED event is fired. You can either
set a handler for this in the traditional AS3 format or you can use the convenient function-pointer
syntax (as shown in the example below) to intercept this event. If you use an invalid ID (or an ID
from a game you don't own, etc.), you will still get this event, but the results will be null.
In the event-handler function, use the latestOtherGameProfile variable to get the information
about the profile. This is an Object with numerous fields, most of which are undocumented. The
ones that are guaranteed to be there are the following:
- a variable called "achievementReceipts" which is an array of objects. Each object has a member called "achievement_id" which is the ID of an achievement the player obtained.
- a variable called "itemReceipts" which is an array of objects. Each object has a member called "item_id" which is the ID of the item the player earned or purchased.
Following is an example of how to request and process this information:

// somewhere in your program, request notification when an "other game profile" event happens
GamerSafe.api.onOtherGameProfileReceived = onOtherGameProfile;
...
// after user has connected, request data for your game sequel (the string is the "_storedPasscode"
// variable from your other games' GamerSafe.as file... the one below is obviously not YOUR game sequel ID, just an example!)
GamerSafe.api.requestOtherGameProfile("G13b5403fe95ea798c1759f5fc17f06a4b288f92f8:1265667543");
...
// when the event comes in, interact with it like so:
private function onOtherGameProfile():void {
for each (var x:in GamerSafe.api.latestOtherGameProfile.achievementReceipts)
{
trace("player earned this achievement ID in other game: " + x.achievement_id);
}
for each (var y:in GamerSafe.api.latestOtherGameProfile.itemReceipts)
{
trace("player owned this item ID in other game: " + y.item_id);
}
}

Parameters

otherGamePasscode:String

requestScoreboardEntries

()

method

public function requestScoreboardEntries(scoreboardID:int = -1):void

Requests an array of the scoreboard entries. Once the entried have been downloaded succefully, a EVT_SCOREBOARD_ENTRIES_RECEIVED
event will be triggered.

Parameters

scoreboardID:int (default = -1)

requestUnregisteredName

()

method

public function requestUnregisteredName():void

Sends a request to retrieve the unregistered players username, determined by the name that
they enter into the scoreboard submission box.

setStyle should be used to set the global theme settings. The acceptable values for name are:

backgroundColor

backgroundAlpha

borderColor

borderWidth

cornerRadius

foregroundColor

foregroundAlpha

middlegroundColor

middlegroundAlpha

dropShadowColor

dropShadowAlpha

fadeColor

fadeAlpha

Parameters

name:String

value:*

showAchievements

()

method

public function showAchievements(configuration:Object = null):void

This function will display a window, overlayed onto your game,
which contains an organised list of possible Achievements that
your players can unlock.
You should pause any gameplay before calling this function.

This function shows a dialog containing a list of Facebook Friends for the logged in user.
They can then select one or more and then publish to their walls. You should call
facebookConfigureAttachment before you open this interface.

Parameters

width:int (default = 400) — how wide to make the dialog.

height:int (default = 350) — how tall to make the dialog.

showFriendsScoreboard

()

method

public function showFriendsScoreboard(scoreboardId:int = -1):void

Shows the requested scoreboard, filtered by facebook friends.
Scoreboard ID should be passed in, or if you leave it as the default (-1)
then the default scoreboard will be loaded.

Parameters

scoreboardId:int (default = -1)

showInterface

()

method

public function showInterface():void

Reverses hideInteface().

showLogin

()

method

public function showLogin(configuration:Object = null):void

This function will display the login form, overlayed onto your
game.
You should pause any gameplay before calling this function.

showMessageBox allows you to display a GamerSafe-styled message box
with a custom message to the player.
The messagebox can either have a "Yes/No" selection, or it can have
just an "OK" button.
You should listen for the events "confirmedYes" and "confirmedNo" which
are fired when the user clicks one of the buttons in the popup box.
If the box is an "Ok-only" box, then "confirmedYes" will always
be fired.

Parameters

title:String — The title text of the message box

text:String — The content of the message box, can be multiple lines long.

isConfirm:Boolean (default = true) — If set to true, the box will have "Yes/No" buttons. If set to false it will only show "Ok"

shopPopup will show a popup box, overlayed on top of your game.
The popup box is unintrusive and will dissapear after around 2
seconds, so it can be displayed at any time - even when a user is
playing the game.

Parameters

text:String — The text that is displayed in the popup. Shouldn't be more than 2 lines long.

This function shows a dialog containing a preview of a Facebook wall post.
The user can see the attachment information and type a comment before they post.
Call facebookConfigureAttachment before you open this interface.

Parameters

uids:Array (default = null) — facebook user IDs of walls to post to.
null is acceptable, and will post only to the logged in user's wall.

width:int (default = 400) — how wide to make the dialog.

height:int (default = 350) — how tall to make the dialog.

showRegistrationForm

()

method

public function showRegistrationForm():void

Show registration form.

showScoreboard

()

method

public function showScoreboard(scoreboardId:int = -1):void

Shows the requested scoreboard. Scoreboard ID should be passed in,
or if you leave it as the default (-1) then the default scoreboard will
be loaded.

Shows the dialog prompting a user to submit their score, or cancel. If the user is not logged in, it will prompt them.
to enter in their name or nicknam. extra text is displayed on the scoreboard
after the score, E.g. "10430 - Great!"

Parameters

score:Number

extra:String

showAsTime:Boolean (default = false)

scoreboardID:int (default = -1)

showShop

()

method

public function showShop(configuration:Object = null):void

showShop() will display your game's personal store. The user
can then browse through your items and purchase them with a single
click.
You should pause any gameplay before calling this function.

This function shows a dialog containing a preview of a Tweet.
The user can see the hashtag and URL information and type a comment before they post.

Parameters

width:int (default = 400) — how wide to make the dialog.

height:int (default = 350) — how tall to make the dialog.

tryAutoLogin

()

method

public function tryAutoLogin():void

If you set autoLogin to FALSE, you can call
this function to attempt to log in using saved credentials at any time.
If there are no saved credentials, then nothing will happen and nothing
will be returned.
If there are saved credentials, the login event will be called.

twitterConfigure

()

method

public function twitterConfigure(hashtag:String, url:String):void

Use this function to configure attachments for twitterPost. This is
where you should set a hashtag for your game, and also a URL. The user is prompted to
use the hashtag as they like, but the URL is automatically linked to the end of the tweet.

Parameters

hashtag:String — A #hashtag that the user is prompted to use by the twitterPublisher.

url:String — A url that is appended to the end of the tweet, if there is room.

twitterConnect

()

method

public function twitterConnect():void

Use this function to pop up the GamerSafe Twitter Login screen in a new window.
Note that the user may already be logged in to Twitter when the GamerSafe session
starts. Use the onTwitterConnected handler to receive notification that they've
finished the login process.

Relevant Events:

onTwitterConnected

onTwitterLoginFailed

onTwitterPostSuccess

onTwitterPostFailed

twitterPost

()

method

public function twitterPost(text:String, useUrl:Boolean = false):void

This function lets you post to Twitter as the logged in user.
You should always prompt the user before calling this function, and you
must not pre-populate the "text" field for them.
The onTwitterPostSuccess or the onTwitterPostFailed
event will fire shortly after you call this function.

Parameters

text:String — A message entered by the user.

useUrl:Boolean (default = false) — Attach the URL set in configureTwitter to the post.