Hoi
Ok I have been getting mp’s about how I did my high score list in my footer ever since I made it. But because I didn’t know any PHP back then the high score list in my footer is all Action Script except the writing to the txt file bit. It is still every buggy and doesn’t work very well. So that’s why I didn’t what to give it to any one because I knew I would never hear the end of all the problems people would have with it. But seen as I have got better at PHP now I made a system where the PHP does all of the work. It works better and it’s dynamic. I made a flash class that formats the score to an array and can communicate with the PHP file so it would be easy to used.
Ok I will explain how to use it, not how it works because I suck at explaining things.
First the PHP file:
Just put it on your web PHP-enabled web server. You can use the PHP file for more then one high score list.
Second the TXT file:
Make an empty txt file and put that on your server. You can have only one high score list for every txt file. Then you have to change the Permissions of the TXT file to 777 you can do this with most ftp programs. The TXT can save up to 100 high scores.
Third the Flash Class
Just copy the script to your root timeline. or use
#include “as file”;
the place of the as file on your computer and its only needed when publishing. Read more about include in the flash help. The usage of the class is as fallows:
Class:
[font=Courier New] yourHighScore = [/font][font=Courier New][color=Navy]new[/color][/font][font=Courier New] HighScore(phpFile, txtFlile, listSize);[/font]
Makes a new HighScore Object
String phpFile is the url of your PHP file on your server
String txtFlile is the url of your TXT file on your server
Int listSize is the length of the high score list that the PHP file returns.
Methods:
[font=Courier New] yourHighScore.getHighScore();[/font]
Gets the high score list.
[font=Courier New] yourHighScore.addHighScore([color=Blue]“name”[/color], score);[/font]
Adds a new score with name to the list (TXT file) but if it’s not in the top100 it will not be saved. If it is but it doesn’t show in you flash movie its because your list is not long enough.
String name is the name of the person that got the score
Int score is the score
Properties:
[font=Courier New] yourHighScore.hsList[];[/font]
This is where the high score list is when it’s loaded with yourHighScore.getHighScore() or yourHighScore.addHighScore()
Each high score is saved in the array as an object as fallows: hsList[0].name, hsList[0].score
Events:
[font=Courier New] onGetHighScore(error);[/font]
This event is call when the high score list is received this happens after yourHighScore.getHighScore(), yourHighScore.addHighScore() is called.
error will be undefined if there are no errors but if there is it will return :
[font=Courier New] Error: Can’t find PHP file (PHP file name)
Error: Can’t read file (TXT file name)
Error: Can’t write to file (TXT file name)[/font]
It has no defense against hackers so you will have to think of things you self
One thing you can do is, put all you file is a dir. with an index file so no one can see your file names. That will stop most of the hackers.
There that’s it I think. Hope I explained it well enough. Sorry for the spelling mistakes i tried my best to remove them all. If someone finds an error or a bug, please tell me.
Here is a zip with the source files.