Games In A Flash: High Score System - ReadMe

The Games In A Flash High Score System is designed to easily add a database-driven high score table to any Macromedia Flash game. The server side runs on PHP and MySQL.

Note that if you will be adding scoring to a Flash game that does not yet contain our High Score System, intermediate knowledge of Flash and your source code is needed.


CONTENTS


Features
Requirements
Installation
Running The Manager For The First Time
Setting Up Games In The Manager
Plugging In A Games-In-A-Flash ENABLED Game
Plugging In Other Flash Games
Contact Us



Features
  • Add a high score table to any Macromedia Flash game!
  • Uses PHP and MySQL.
  • Supports any number of games per license.
  • Web-based High Score Manager allows you to easily add/remove games, adjust settings and view scores.
  • Intelligent word censor filters offensive content from submitted player names, with editable word list.
  • Scores can be automatically cleared periodically — daily, weekly, monthly, quarterly, annually, or never. Cleared scores can be emailed to you for your records.
  • Optionally ask players for their email addresses — great for entering winners from each play period into contests, etc — encourages people to play more often!
  • Challenge-A-Friend feature — When a game is over, a player can email their score to friends, challenging them to beat it. This is a great "viral marketing" scheme for increasing traffic to your game.
  • MD5 Encryption is used to discourage attempts to "hack" the high score table or "fake" new scores.
  • All source code is provided — make modifications as you see fit, as long as the source is not redistributed.



Requirements
Client Side:
  • Macromedia Flash 5, Flash MX, MX 2004, or later.
Web Server Side:
  • PHP (www.php.net) WITH MySQL module installed
  • MySQL (www.mysql.com) WITH a pre-created database. Your MySQL account needs full INSERT, UPDATE and DELETE permissions to this database.



Installation
1. Unzip the "giaf_highscore.zip" archive.

2. Using a text editor, open the "hs_login.php" file. This file contains all the information needed to connect to your MySQL server, and must be modified to match your configuration. The first four variables listed pertain to the MySQL username and password, hostname, and database name for your configuration. Set these variables to the appropriate values for your server. If you are unsure what these values are, contact your system administrator. The final variable, "$hs_password", is used to protect the High Score Manager from unauthorized use. Change the value to the password you'd like to use.

3. With your favorite FTP program, upload the "hs_login.php" file to your server.
*** IMPORTANT NOTE: Because this file contains sensitive password information, IT IS RECOMMENDED you upload this file to a directory that is not visible to the public, such as a directory ABOVE your web root. ***

4. Using a text editor, open the "hs_global.php" file. The first line of code in this file looks like this: $login_file = "../hs_login.php"; Change this value to point to the location of the "hs_login.php" file you just uploaded. In the example here, the "../" is a reference to the "parent" directory. You can also use an absolute reference (Example: "/home/users/blah/hs_login.php").

5. FTP the following files to your server's "web root" directory. These files need to be in a web-visible directory:

  • hs_global.php
  • hs_scores.php
  • hs_manager.php
Your server-side files are now ready for use! Continue to the next section to learn about creating high score tables and changing settings.



Running The Manager For The First Time
1. After setting up the 4 PHP files from the previous instructions, you are ready to start the High Score Manager. Open your web browser, and point it to the hs_manager.php file located on your web server (for example: http://yoursitename.com/hs_manager.php). You may want to bookmark this page for easy access.

2. When the page opens, you will be prompted for a password. The password for the Manager is set in "hs_login.php". If you didn't alter this value, use the default password, "password" (no quotes). Remember that passwords are case-sensitive!

3. If there were any errors connecting to the MySQL server or selecting your database, you will be notified at this point. Otherwise, if it is your first time accessing the Manager, you will be notified that 3 tables need to be created to store data. Click "Continue" to let the Manager create these tables for you.



Setting Up Games In The Manager
1. Once you get to the Games list in the Manager, you can click "Add a Game" to create a new high score table for use with a single game. Edit its settings to change its name, number of scores to store, whether to periodically clear the scores, and so on. You can also view recorded scores for each game and clear them, optionally emailing them to you before they are erased.

2. The Global Settings button on the Games page allows you to set an email address for emailing scores to (optional) and also modifying the list of "Bad Words" that will be censored from player names.

3. Once you have configured your game's high score settings, the important piece of information to note is the "ID" listed to the left of the game name. Your first game should have an ID of 1. This ID is used to allow a Flash game to communicate with the correct high score table.



Plugging In A Games-In-A-Flash ENABLED Game
Follow these instructions if you have licensed a Games-In-A-Flash game that is ENABLED for the high score system. These are games that already contain the high score component, but need to be configured to communicate with your server.
1. Launch Macromedia Flash. Open the FLA file of the Games-In-A-Flash game you want to plug into your high score table. Games-In-A-Flash files that contain the high score component typically end in "_hs".

2. Open the Scene palette (Press Shift-F2 if it is not already visible) and click on the first scene, which may be labeled as "preload" or something similar.

3. Look for a gray box labeled "HIGH SCORE SETTINGS" just off the upper-left corner of the stage, and click on it to select it. Press Ctrl/Cmd-F3 to open the Properties panel if it isn't already visible.

4. On the Properties panel, click the Parameters tab to display the high score component's options. The two parameters you are concerned with are highscore_url and game_id.
Adjust these settings as follows:

ParameterDescription
highscore_urlEnter the full URL to the hs_scores.php file on your server. This file should have been already uploaded in the "Installation" section above.
game_idEnter the "ID" value for this game's high score table, which is displayed to the left of the game name in the High Score Manager. If you enter an incorrect ID, the system might enter scores into the wrong game.


The high score system's parameters

4. Your high score system should be plugged in and working now. Choose Control->Test Movie to export your game and try the high score system.

Note:

  • If your game is loaded from a server, the domain of the game's swf file and the domain of the hs_scores.php file must be the same. In other words, if the game is located at http://somesite.com/game.swf, it cannot use a high score system located at http://anothersite.com/hs_scores.php. This is a security feature built into Flash.



Plugging In Other Flash Games
Follow these instructions if you are plugging in a game that does not already contain our high score system.
1. Launch Macromedia Flash. Choose File->Open As Library. Select the "hs_client.fla" file, which has been provided in the ZIP file, and click Open. (If your version of Flash does not have the "Open As Library" function, open the file normally and then press F11 to open the Library for the file.)

2. Open your game's FLA file. Use the Scene palette to switch to your game's first scene. This is typically used as a preloader or instructions page. Find the library palette for "hs_client.fla" and drag a copy of the "giaf hs settings" component onto the stage. Position the component so it sits off the upper-left corner of the screen. This will prevent the component from being visible to the user.

A typical set of scenes for a game


Drag the high score component onto the stage of the first scene

3. With the high score settings component on the stage selected, open the Properties Panel (Press Ctrl/Cmd-F3 if it is not already visible). Click the Parameters tab to show the component's options.
Adjust these settings as follows:

ParameterDescription
highscore_urlEnter the full URL to the hs_scores.php file on your server. This file should have been already uploaded in the "Installation" section above.
game_idEnter the "ID" value for this game's high score table, which is displayed to the left of the game name in the High Score Manager. If you enter an incorrect ID, the system might enter scores into the wrong game.
score_variableThe high score system needs to know what the player's score is. Your game should be programmed to store the score into a variable on the main (_root) timeline. This value should be the variable name on the root level that contains the score. For example, a value of "final_score" will look at _root.final_score for the current player's score.
button_labelThis value can either be "Continue" or "Play Again" and changes the text on the high score system's final page accordingly. For example, if you want to direct the player to the next scene, rather than playing the game again, the "Continue" label is more appropriate.


The high score system's settings

4. Now it's time to add the score table's interface. Presumably, your game is divided into scenes and has been programmed to go to a particular scene when the game ends. This scene might be called "Game Over", "End", or "Lose". Use the Scene palette to locate and edit this scene.

Create a new layer in your "Game Over" scene, and drag a copy of the "giaf hs interface" component from the hs_client.fla Library onto the stage of your game. Position the high score table until your are satisfied with its location and appearance.


Position the high score interface as desired


The high score interface, placed in the scene

5. Your high score system should be plugged in and working now. If you need to record scores from more than one place (for example, from a "You Win" scene as well as a "You Lose" scene), simply repeat step 4 for each additional scene that will be used to record scores. Choose Control->Test Movie to export your game and try the high score system.

A few things you should be aware of:

  • The game should be programmed to go to a scene containing the high score interface when the game ends. The high score system will not work unless the scene containing the high score system plays.
  • The game should provide the final score as a _root variable in the scene containing the high score system.
  • If your game is loaded from a server, the domain of the game's swf file and the domain of the hs_scores.php file must be the same. In other words, if the game is located at http://somesite.com/game.swf, it cannot use a high score system located at http://anothersite.com/hs_scores.php. This is a security feature built into Flash.
  • When the "Continue" or "Play Again" button is clicked in the high score system, the main timeline of your movie will continue playing. You can create a scene after the high score's scene to direct the playback to a previous scene (to facilitate a "Play Again" function) or to whatever additional content you desire.



Contact Us

Click here to contact us for questions, licensing information, customer support, or technical questions.

© 1998-2004 Eyeland Studio Inc. All Rights Reserved.