stop();
// Show scoreboard with loaded ranks, names and scores for this page
showScores = function() {
for (var i=10; i>0; i--) {
var n = scoreboard_lv["name" + (page + i)];
var s = scoreboard_lv["score" + (page + i)];
var l_mc = this["line" + i + "_mc"];
l_mc.rank_txt.text = (page + i) + ".";
l_mc.name_txt.text = n.length ? n.toLowerCase() : "-";
l_mc.score_txt.text = s.length ? s.addCommas() : "-";
l_mc.rank_txt.textColor = l_mc.name_txt.textColor = l_mc.score_txt.textColor = (game_so.data.playerName.length && n.toLowerCase() == game_so.data.playerName.toLowerCase()) ? 0xFFFFFF : 0x7788AA;
l_mc._visible = true;
loading_mc._visible = false;
}
};
page = 0; // Start at page 0
maxScore = 100; // Maximum amount of scores to show is set by high score script on server
// Send score, load new scoreboard
scoreboard_lv = new LoadVars();
if (score > 0 && game_so.data.playerName.length > 0) {
// If there's a score and a playerName, send it to high score script
scoreboard_lv.score = score;
scoreboard_lv.name = game_so.data.playerName.toLowerCase();
}
scoreboard_lv.game = "tetris";
// Change this URL to point to the scores script on your server
scoreboard_lv.sendAndLoad("
http://www.neave.com/games/games_score_text.php", scoreboard_lv, "POST");
// Scoreboard data handler
scoreboard_lv.onLoad = function(success) {
if (success) {
// Access to high score script successful
if (Boolean(scoreboard_lv.success)) {
// Script returns success=1 and no error
next_btn._visible = true; // Allow clicking on next button
// Maximum scores to be shown set by server side script (multiple of 10)
if (scoreboard_lv.maxScore.length > 0) maxScore = Number(scoreboard_lv.maxScore);
showScores();
}
else {
// Script returns an error message
loading_mc.errorMsg = scoreboard_lv.errorMsg.toLowerCase();
loading_mc.gotoAndStop(2);
}
}
else {
// Could not access high score script
loading_mc.errorMsg = "could not access scores.";
loading_mc.gotoAndStop(2);
}
};
score = 0; // Reset score
next_btn._visible = last_btn._visible = false; // Hide last buttons
// Last 10 button
last_btn.onPress = function() {
page -= 10;
if (page < 0) page = 0;
if (page < 10) last_btn._visible = false;
next_btn._visible = true;
showScores();
};
// Next 10 button
next_btn.onPress = function() {
page += 10;
if (page > maxScore) page = maxScore;
if (page > maxScore - 20) next_btn._visible = false;
last_btn._visible = true;
showScores();
};
// New Game button
newGame_btn.onRelease = function() {
gotoAndStop("Intro", 2);
};