How to make top 3 scores from an array to the 3 different text fields and sort them highest to lowest scores? My code:
var top3Array:Array = [];
var totalScore = int((numeratorCounter/denominatorCounter)*100)/100;
fucntion scoreBoard(): void{
top3Array.sortOn("totalScore");
for(i:int = 0, i < 3; i++)
{
count1.text = String(count);
score1.text = String(top3Array[0]);
}
}
Its a little unclear from your question but it sounds like you want to add all of your scores to an array, take the top 3 and display them in some text fields?
As @Organis mentioned, the contents of your array does determine what kind of sort you would need to perform.
If the scores array just contains a list of numbers then you need only use the .sort() function rather than .sortOn()
On the assumption that each score is pushed to an array named allScores each time the player dies you could use code similar to this: