A Flash Developer Resource Site














Internet Commerce

Partners & Affiliates














Developer Channel

internet.com


Featured Flash FLA
Gallery Downloads 11303 Flash Movies | 7 New Flash Movies Added
What's New | Top 100

Featured FLA

» Author: Nitin Tikhe
» Title: Cart
» Description: This Animation Tut is a fun and useful for kids below 15 years. Watch the Flag, Doors, Stick and Horse movements.
» More by Nitin Tikhe


Random FLAs | Add Flash Movie
Featured Flash Site
Gallery Downloads 6008 Flash Sites | 0 New Flash Links
What's New | Top 100 Flash Site

Featured Site

» Posted in the Flash Kit Links section
» Title: Banana Swimwear
» Description: This is a banana swim wear interactive catalog we designed and animated in Flash


Random Links | Add your own Flash Related Links
Flash Tutorials 1255 Tutorials 7 New Tutorials Added!
What's New | Top100

» Make flash video player for broadcasting live streaming video / TV on website
» How to convert the project file of Flash Demo Builder 2.0 into FLV file
» FLV to PSP for Mac - How to convert YouTube video to PSP on mac
» How to Convert FLV to MP4 for Playback on iPod
» how to download and convert youtube video to AVI with Leawo Free FLV converter
» Flash Multi-player Game Tutorial - TicTacToe
» How to make Flash elearning tutorials with screen recorder?
» Fader API:Slideshow with MovieClips on stage
» How to convert MS PPT file into an FLV File
» Unknown Tag: Title10
Random Tutorial | Add Site

Network Design Manager
The Computer Merchant, Ltd
US-VA-Hampton

Justtechjobs.com Post A Job | Post A Resume


Tutorials Home What's New Top Rated Submit myTutes Random!

Search Tutorials


Tutorials Tutorials » Games

Categories High-score list using PHP
Author: Glen Rhodes | Website: http://www.glenrhodes.com |

 
Page 4
«prev 1 2 3 4 5 6 next»

Adding Flash

So, now we'll bring this functionality into Flash. We're going to build a simple Flash application which adds a name and score to the list and displays the whole list on screen.

  1. First, create a blank movie.
  2. Insert ten variable text boxes in a column with the variable named NAME0 to NAME9 and ten more next to each corresponding text box named SCORE0 to SCORE9. It should look like this:

    The text boxes on the left are the NAME text boxes and the ones on the right are the SCORE text boxes.
  1. Select all the text boxes and convert them to a movieClip by pressing F8. Call the new movieClip scoretable. Set the instance of the movieClip to scoretable as well.
  2. Within the scoretable movieClip fix up the graphics as you see fit, to make the score table more presentable. I've made mine look like this:
  3. To submit a new name and score to the high score list and then update the table on screen, use the following actionscript
_root.scoretable.filename = "scores/demo.sco";
_root.scoretable.scoresize = 10;
_root.scoretable.action = "INSERT";
_root.scoretable.viewtype = "FLASH";
_root.scoretable.winname = name;
_root.scoretable.winscore = score;
_root.scoretable.loadVariables("http://www.myscore.com/scores.php", "GET");

This code can be placed anywhere in your game, because it accesses scoretable via the _root path. What we're doing is adding name and score to the file scores/demo.sco. Also, because we've specified viewtype to be FLASH, then a string of variables (including our recent addition) will be returned to Flash, and sent to the scoretable movieClip. Since our movieClip is filled with text box variables that have names which match the incoming score data, the on-screen score table will automatically be updated with the newly received scores.

Let's say that the player "Glen" has just died, with a score of 29220. We can present them with a game over screen that asks them for their name. The _root variable score contains the score, and their name is placed in the _root variable name. We present them with an "OK" button, that has the following code attached to it:

on (release)
{
 _root.scoretable.filename = "scores/demo.sco";
 _root.scoretable.scoresize = 10;
 _root.scoretable.action = "INSERT";
 _root.scoretable.viewtype = "FLASH";
 _root.scoretable.winname = _root.name;
 _root.scoretable.winscore = _root.score;
 _root.scoretable.loadVariables("http://www.myscore.com/scores.php", "GET");
}

Now, as long as our _root.scoretable._visible is true (the scoretable is visible, and on screen), then we'll see the new scores!

As more people play the game, the list will fill up, and the best will be at the top. If you wanted to display the score table without adding new names to the list (at the beginning of the game, for example, at the starting screen), you would simply set _root.scoretable.action to "VIEW" instead of "INSERT". Remember, if you ever send through a "CLEAR" action, then the table will be reset to names of "none" and scores of 0.

The location of your game's SWF file, and the location of the high-score server (scores.php) and table must be at the same domain. So, if your game is at http://www.myscore.com then scores.php and the scores folder must also be in that location. This is because Flash has a security limitation surrounding the posting and retrieval of variables from sites other than your own. The demo SWF included with this tutorial is programmed to look at www.myscore.com; you must replace this with the actual location of your webserver.

That's it. The rest is up to you - you have to build the games around this.

«prev 1 2 3 4 5 6 next»

» Level Intermediate

Added: : 2001-08-24
Rating: 8.46 Votes: 353
Hits: 3895
» Author
No details available
» Download
Download the files used in this tutorial.
Download (147 kb)
Get conversion and unzipping tools for PC and Mac here!

» Forums
More help? Search our boards for quick answers!

Please rate this tutorial, 10 is the top rating, you can also click the comments link to read/write a review.
10 9 8 7 6 5 4 3 2 1
Read or Post Comments