Packagecom.kongregate.as3.client.services
Interfacepublic interface IStatServices

The interface for the Statistics Services. This interface indicates which methods are available to the developer for statistics submission.



Public Methods
 MethodDefined by
  
submit(name:String, value:Number):void
Submits a single statistic to the server.
IStatServices
  
submitArray(stats:Array):void
Submits an array of statistics all at once, instead of just a single statistic.
IStatServices
Method detail
submit()method
public function submit(name:String, value:Number):void

Submits a single statistic to the server. This will generate no response, but will attempt to deliver the statistic to the server as best it can.

Parameters
name:String — Name of the statistic. This must match the name you have specified in the statistics editor on the upload page.
 
value:Number — The value to submit for the statistic. Even though this method accepts numbers, the server will truncate the value into a 64-bit signed integer.

Example
  import com.kongregate.as3.client.KongregateAPI;
  var kongregate:KongregateAPI = KongregateAPI.getInstance();
  kongregate.stats.submit ( "Coin", 1 );

submitArray()method 
public function submitArray(stats:Array):void

Submits an array of statistics all at once, instead of just a single statistic. This is typically more efficient and less likely to be rate limited than sending stats one at a time.

Parameters
stats:Array — An array of Objects with name and value attributes.

Example
  // Import the Kongregate library
  import com.kongregate.as3.client.KongregateAPI;
  
  // Get a reference to the component API
  var kongregate:KongregateAPI = KongregateAPI.getInstance();
  
  // Put our stats in an array
  var statsArray:Array = new Array();
  statsArray.push ( {name:"GamesWon", value:1} );
  statsArray.push ( {name:"GamesLost", value:1} );
  
  // Submit the data through the stats service
  kongregate.stats.submitArray( statsArray );

Shorthand example:
  import com.kongregate.as3.client.KongregateAPI;
  KongregateAPI.getInstance().stats.submitArray( [{name:"GamesWon", value:1}, {name:"GamesLost", value:1}] );