PackageAndrograde
Classpublic class User
InheritanceUser Inheritance flash.events.EventDispatcher

All of the stuff you can do with a User of a game Never instantiate this directly, use API.user, API.login, API.register or API.getUserInfo

See also

API.user
API.login
API.register
API.getUserInfo


Public Properties
 PropertyDefined by
  experience : int
[read-only] returns how much Andrograde experience the user has
User
  identity : String
[read-only] returns the identity (user name + network) of this user
User
  level : int
[read-only] returns what level the user is on
User
  name : String
[read-only] returns the user name of this user
User
  points : int
[read-only] returns how many Andrograde points the user has
User
  premium : Boolean
[read-only] returns whether the user is a premium user or not, you can use this to give discounts to premium users
User
Public Methods
 MethodDefined by
  
getRank(stat:String, type:uint, callback:Function):void
Gets the rank of this user in regards to a particular stat
Note: This is 1 based (1st, 2nd, 3rd ...) so you will need to subtract 1 to correlate it with the highscores array returned by API.getHighScores
calls 'callback(ronk:uint):void' when it's done (rank = 0 if there is an error)
User
  
getStat(statName:String):Object
Checks the value of a stat for this user
User
  
owns(item:String):Boolean
Checks if the user has bought this item
User
  
refresh(callback:Function = null):void
refreshes the player information from the server calls 'callback(success:Boolean):void' when it's done
User
  
setStat(statName:String, value:Object, type:uint, callback:Function = null):void
sets a stat calls 'callback(success:Boolean):void' when it's done
User
Public Constants
 ConstantDefined by
  STAT_ADD : uint = 1
[static] add this value to the old stat value
User
  STAT_MAX : uint = 3
[static] sets the stat to the highest value of either the original stat or the new value
User
  STAT_MIN : uint = 4
[static] sets the stat to the lowest value of either the original stat or the new value
User
  STAT_REPLACE : uint = 0
[static] replace the stat that was there with the new one
User
  STAT_SUBTRACT : uint = 2
[static] subtract this value from the old stat value
User
Property detail
experienceproperty
experience:int  [read-only]

returns how much Andrograde experience the user has

Implementation
    public function get experience():int
identityproperty 
identity:String  [read-only]

returns the identity (user name + network) of this user

Implementation
    public function get identity():String
levelproperty 
level:int  [read-only]

returns what level the user is on

Implementation
    public function get level():int
nameproperty 
name:String  [read-only]

returns the user name of this user

Implementation
    public function get name():String
pointsproperty 
points:int  [read-only]

returns how many Andrograde points the user has

Implementation
    public function get points():int
premiumproperty 
premium:Boolean  [read-only]

returns whether the user is a premium user or not, you can use this to give discounts to premium users

Implementation
    public function get premium():Boolean

Example
if (API.user.premium) API.user.buy(cost / 2, "cool stuff"); else API.user.buy(cost, "cool stuff");

Method detail
getRank()method
public function getRank(stat:String, type:uint, callback:Function):void

Gets the rank of this user in regards to a particular stat
Note: This is 1 based (1st, 2nd, 3rd ...) so you will need to subtract 1 to correlate it with the highscores array returned by API.getHighScores
calls 'callback(ronk:uint):void' when it's done (rank = 0 if there is an error)

Parameters
stat:String — which stat to get the rank of
 
type:uint — either HIGHSCORE_HIGHEST (from the top) or HIGHSCORE_LOWEST (from the bottom)
 
callback:Function

See also

getStat()method 
public function getStat(statName:String):Object

Checks the value of a stat for this user

Parameters
statName:String — the name of the stat to check

Returns
Object — what the stat is currently set to
owns()method 
public function owns(item:String):Boolean

Checks if the user has bought this item

Parameters
item:String — the item to check

Returns
Boolean — true if the user has bought this item
refresh()method 
public function refresh(callback:Function = null):void

refreshes the player information from the server calls 'callback(success:Boolean):void' when it's done

Parameters
callback:Function (default = null)
setStat()method 
public function setStat(statName:String, value:Object, type:uint, callback:Function = null):void

sets a stat calls 'callback(success:Boolean):void' when it's done

Parameters
statName:String — the name of the stat to set
 
value:Object — what to set it to, can be any type
 
type:uint — how to handle comparing to the value that is already there for that stat
 
callback:Function (default = null)

See also

Constant detail
STAT_ADDconstant
public static const STAT_ADD:uint = 1

add this value to the old stat value

STAT_MAXconstant 
public static const STAT_MAX:uint = 3

sets the stat to the highest value of either the original stat or the new value

STAT_MINconstant 
public static const STAT_MIN:uint = 4

sets the stat to the lowest value of either the original stat or the new value

STAT_REPLACEconstant 
public static const STAT_REPLACE:uint = 0

replace the stat that was there with the new one

STAT_SUBTRACTconstant 
public static const STAT_SUBTRACT:uint = 2

subtract this value from the old stat value