| Package | com.kongregate.as3.client.services |
| Interface | public interface IHighScoreServices |
See also
| Method | Defined by | ||
|---|---|---|---|
|
requestList(callback:Function):void
Retrieves a high score list from the server.
| IHighScoreServices | ||
|
setMode(mode:String):void
Sets the mode to be used, such as 'Hard', 'Normal', 'Easy', which is used
for submitting and retrieving high score lists.
| IHighScoreServices | ||
|
submit(score:Number, mode:String = null):void
Submits a high score to the server.
| IHighScoreServices | ||
| requestList | () | method |
public function requestList(callback:Function):voidRetrieves a high score list from the server.
The object sent to the return method will have the following properties:
success - Boolean. Whether the call was successful. When testing locally, this parameter will be false.Parameters
list - Array. An ordered list of objects containing the properties username and score for each of the players on the list.
callback:Function — A method to pass the high score data back to once the server responds.
|
See also
import com.kongregate.as3.client.KongregateAPI;
var kongregate:KongregateAPI = KongregateAPI.getInstance();
// Create a text field to display the scores
import flash.text.TextField;
var my_txt:TextField = new TextField();
my_txt.width = 200;
my_txt.height = 200;
this.addChild ( my_txt );
// Request the list
kongregate.scores.requestList ( scoresCallback );
function scoresCallback ( result:Object ):void
{
my_txt.appendText("High score result, success=" + result.success );
for ( var i:int = 0; i < result.list.length; i++ ){
var position:int = i + 1;
my_txt.appendText("\n"+position + ". " + result.list[i].username + " - " + result.list[i].score );
}
}| setMode | () | method |
public function setMode(mode:String):voidSets the mode to be used, such as 'Hard', 'Normal', 'Easy', which is used for submitting and retrieving high score lists. The name of the mode is up to the developer to decide and it affects the display name used in the leaderboards (e.g. 'HighScore-Hard)'.
Once you set the mode, any scores sent using the submit() method
will be saved under that mode, unless you use the mode parameter when calling submit().
mode:String — A string name indicating what mode you would like to set.
|
import com.kongregate.as3.client.KongregateAPI; var kongregate:KongregateAPI = KongregateAPI.getInstance(); kongregate.scores.setMode ( "Hard" );
| submit | () | method |
public function submit(score:Number, mode:String = null):voidSubmits a high score to the server.
Parametersscore:Number — The value of the score to submit
|
|
mode:String (default = null) — An optional value specifying the mode to submit this stat under.
If no value is submitted, the last mode that was set will be used. Note:
submitting a value will change the high score mode just the same as using
setMode() would. If you are worried you will get modes confused,
avoid this parameter and use the setMode() method instead.
|
See also
import com.kongregate.as3.client.KongregateAPI; var kongregate:KongregateAPI = KongregateAPI.getInstance(); kongregate.scores.submit ( myScore );
setMode() method:kongregate.scores.setMode ( "Hard" ); kongregate.scores.submit ( myScore );
setMode():kongregate.scores.submit ( myScore, "Hard" );