| Package | com.kongregate.as3.client.services |
| Interface | public interface IStatServices |
| Method | Defined 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 | ||
| submit | () | method |
public function submit(name:String, value:Number):voidSubmits 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.
Parametersname: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.
|
import com.kongregate.as3.client.KongregateAPI; var kongregate:KongregateAPI = KongregateAPI.getInstance(); kongregate.stats.submit ( "Coin", 1 );
| submitArray | () | method |
public function submitArray(stats:Array):voidSubmits 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.
Parametersstats:Array — An array of Objects with name and value attributes.
|
// 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 );
import com.kongregate.as3.client.KongregateAPI;
KongregateAPI.getInstance().stats.submitArray( [{name:"GamesWon", value:1}, {name:"GamesLost", value:1}] );