Search Tutorials
Highscore Tutorial One of the little things for a nice Flash game is a tutorial. It's making people to go back to your game and play it again to win from the competition. It's a way of competition and interactivity between the players to do their best and win as much points as they can.
Things you need
The first few things.
Upload _data.php/get_score.php/install.php/new_score.php to your website's root directory. Run the install.php script. When it sais 'Done..', you can delete the install.php file from your website. Done. Why PHP/MySQL? PHP, PHP Hypertext Processing is a free server-based scripting language that is free and provided by a lot webserver/hosting companies. Other than that, it's a very fast language, faster then ASP(from Micro$oft). MySQL is the perfect database partner for PHP. Together they can be fast and above all secure.
Adding new people to the scores.
_root.add_pass = "{same as $pass in _data.php}";
_root.name = _root.variableYouUsedInTheGameForThePlayersName;
_root.score = _root.variableYouUsedInTheGameForThePlayersScore;
getURL("new_score.php", "", "POST");
That's it! The PHP script itself makes sure the player gets added to the database and all other things you don't need to worry about.
Showing the Highscore in Flash.
I am not taking this anyfurther, but you can understand that you can make the looks of your Highscore list somewhat nicer than standard.. ;) Now use the following Actionscript code to load the variables from the database back into Flash: loadVariablesNum("get_score.php?flash=1", 0);
Now the variables get loaded into the _root. But if you have your Highscore list in a movieclip, you should use this code:
loadVariables("get_score.php?flash=1", "_root.scoretableOrAnyOtherMCname");
The location of the Flash game's SWF file and the location of the Highscore scipts must be at the same domain. (And in these Actionscript code, it must be in the same folder as well.) This is a standard security feature from Macromedia Flash. It can't be changed, live with it.
Including the Highscore list on your webpage.
Your page where you want it to show must be a PHP page as well. We take 'index.php' as an example. The $dis_file variable in _data.php must be the same as this page. Now, where ever you want the Highscore table to appear on your page, you include this:
<?php
include("http://www.ssj-games.com/get_score.php");
?>
You can change some graphics from the HTML table in _data.php if you want, but look out to only use ' in the code instead of ". That is VERY important.
Ending
If you have any comments, questions or suggestions, you can email me at jeroendenhaan@yahoo.com, or visit my site at http://www.ssj-games.com (comes online very soon..^^)
|
|||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||||
|