A Flash Developer Resource Site

Page 1 of 4 1234 LastLast
Results 1 to 20 of 65

Thread: [Resolved] [Resolved] [Resolved] [Resolved] [Resolved] [Resolved] [Resolved] [Resolved] [Resolved] [

  1. #1
    Flash Developer on a break
    Join Date
    Jun 2001
    Location
    The Netherlands
    Posts
    1,370

    v1.3

    v1.3 changes November 26, 2002: _root.add_pass in the AS that inputs new data into the database changed to _root.pass.

    __________________________________________________ ________________
    Ok... Lets get started. This is my first tutorial, so enjoy!

    http://www.ssj-games.com/tut/highscore_tut.zip

    Highscore Tutorial

    One of the little things for a nice Flash game is a highscore list. 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
    1. A webserver enabled with PHP and MySQL.
    Almost all unix/linux webservers have these two, because they are free for everyone. If you don't know if you have PHP4/MySQL enabled, contact your Hosting Company.
    2. Notepad.
    Or a similar text editing program.
    3. A FTP program to upload your files.
    CuteFTP or WS_FTP are two examples.
    4. The files that come with this tutorial. (highscore_tut.zip)
    5. Your nice Flash game.
    Duh..

    The first few things.
    Open '_data.php'.
    This is rather important. You need to change a few things here. You need to input the right usernames/passwords/game name/other things.
    You will have to change at least numbers 1 to 6. The numbers 1-3 are the few things you need to enter to make contact with the MySQL database. You've got those from your Hosting Company. If not, ask them.
    7-14 are optional, they don't need to be changed to get it all working. All things are rather straigtforward.

    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.

    Caching
    You will notice that sometimes I have added a random variable. This is to prevent caching. It's a common problem of using PHP in combination of flash. To add a random number to the url, you make sure the output of the script is retrieved from the server instead of your hard-drive.

    Adding new people to the scores.
    Ok, now we are going to start with the Flash part.
    When you want to send your highscores from Flash to the MySQL server, you'll need this Actionscript:
    Code:
    	_root.pass = "{same as $add_pass in _data.php}";
    	_root.name = _root.variableYouUsedInTheGameForThePlayersName;
    	_root.score = _root.variableYouUsedInTheGameForThePlayersScore;
    	somevar = random(9999);
    	loadVariablesNum("new_score.php?" add random(999), 0, "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.
    This is rather easy. Make 10 variable text boxes in a column.(Or the number you used in the _data.php file as $st_size.) These dynamical text boxed are named 'name1' to 'name10'. (Or different, again corresponding to the Standard Size inputted in _data.php.)
    Then make 10(Or blab, bla, you know..) dynamical variable text fields next to each corresponding text box called 'score1' to 'score10'.

    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:
    somevar = random(9999);
    loadVariablesNum("get_score.php?flash=1&" add random(999), 0);

    Now the variables get loaded into the _root. But if you have your Highscore list in a movieclip, you should use this code:
    somevar = random(9999);
    loadVariables("get_score.php?flash=1&" add random(999), "_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.
    It is possible to include a HTML highscore list on your webpage. This is realy nice for your site's visitors.

    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:

    Code:
    	<?
    		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
    Well, that's about it. You can use this to make your own nice Highscore for every game you want.

    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(What comes online very soon..^^)

    That's it. If you encounter any problems or so, respond please..

    Jeroen

    [Edited by jeroen84 on 06-02-2002 at 06:42 AM]
    Last edited by jeroen84; 11-26-2002 at 09:06 AM.

  2. #2
    Flash Developer on a break
    Join Date
    Jun 2001
    Location
    The Netherlands
    Posts
    1,370
    And if someone wonders why the table looks so much like the one from Glen... It's just because I used his HTML code from his table. I was too lazy to make my own after scripting all of the PHP. (Can ya blame me?)

    However, if you want to know. You can change the table with editing the _data.php file.
    This part:
    // HTML Table Properties (Use ' in the html code instead of ".)
    //10. Top Font properties
    $t_font = "<font color='#FFFFFF' face='Arial, Helvetica, sans-serif'>";
    //11. Main Font properties
    $m_font = "<font color='#750000' size='2' face='Arial, Helvetica, sans-serif'>";
    //12. Table Properties
    $table_prop = "<table cellpadding='2' cellspacing='2' border='0' width='152'>";
    $table_width = "152";
    //13. Top Row Color
    $t_color = "#000033";
    //14. Main Rows Color
    $m_color = "#666666";


    Oh, and if you want to see an example:
    http://www.ssj-games.com/tut/index.php

    -Jer'ul

  3. #3
    Flash Developer on a break
    Join Date
    Jun 2001
    Location
    The Netherlands
    Posts
    1,370
    Ok, I've send the tutorial to the Flashkit Tutorial section.

    Come on people... Where are ya response? All stuck in the other thread?

  4. #4
    Elvis...who tha f**k is Elvis? phreax's Avatar
    Join Date
    Feb 2001
    Posts
    1,836
    Hey Jeroen, I don't have the time to go through all of that...I'm at work! Looks good though! I'll look into it later

  5. #5
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    Originally posted by jeroen84
    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.
    lol

    every Flash game should have tutorial

    But seriously, thanks jeroen, good work.

  6. #6
    Elvis...who tha f**k is Elvis? phreax's Avatar
    Join Date
    Feb 2001
    Posts
    1,836
    How's 'bout the "YOU CAN ONLY HAVE 1 SCORE ON THE BOARD"-thingie...that's what I really missed in Glen's version!

  7. #7
    Flash Developer on a break
    Join Date
    Jun 2001
    Location
    The Netherlands
    Posts
    1,370
    tonypa -Hey.. I had to think of some introduction.

    phreax -What exactly do you mean? That there can be only one person on the Highscore list? That can be modified in the _data.php file. Just change the $st_size and $sec_size variables.

    Or do you mean that a person can only BE on the list one time and then improve his own score? (Aka unique names?)
    That is also modiefied in the _data.php file.
    Just put the $u_user variable to 1. (This is already standard.)

    Btw, Glen's version is hackable. Everyone can CLEAR the table if he wants.

  8. #8
    Elvis...who tha f**k is Elvis? phreax's Avatar
    Join Date
    Feb 2001
    Posts
    1,836
    Cool, thanks Jeroen, I am gonna try it out later when I get home Yeah I realise that Glen's version had these small security issues but since I couldn't do it myself, his was the best alternative! ...and yes unique names on the board was exactly what I meant...man I gotta speak some more english!

  9. #9
    Flash Developer on a break
    Join Date
    Jun 2001
    Location
    The Netherlands
    Posts
    1,370
    Great. English isn't my primary language as well.

    This is to all: I hope you all like it.

  10. #10

    Smile thanks

    I will test it tomorrow with my new game: On Ice
    Thanks for the time putting all files and code together. I appreciate it!

    TB

  11. #11
    Flash Developer on a break
    Join Date
    Jun 2001
    Location
    The Netherlands
    Posts
    1,370
    Bumping this...

    -Jer'ul

  12. #12
    GamerGirl Liallan's Avatar
    Join Date
    Nov 2001
    Location
    the Netherlands
    Posts
    127
    Great!

    I finally found a host that supports php, so I'll try it, end let ya know what I think. Looks good though!

    applauds..

  13. #13
    Flash Developer on a break
    Join Date
    Jun 2001
    Location
    The Netherlands
    Posts
    1,370
    /me bumping this

    Does someone know how long you have to wait before you're mailed back after you've send a tutorial with the Flashkit Tutorial submissions form?

    Maybe I should resend it... :-/

  14. #14
    Flash Developer on a break
    Join Date
    Jun 2001
    Location
    The Netherlands
    Posts
    1,370
    Bumping this again, 'cause Highscores are mentioned a lot these last days..

    I've changed the text a little and fixed a few minor things in the php scripts.

    Jeroen

  15. #15
    Senior Member
    Join Date
    Mar 2002
    Location
    Canada
    Posts
    470
    i'm bumping this thread because it is so useful!

  16. #16
    School bully
    Join Date
    Dec 2001
    Posts
    303

    Lightbulb

    bumping. THanx I needed one of these.

  17. #17
    Flash Developer on a break
    Join Date
    Jun 2001
    Location
    The Netherlands
    Posts
    1,370
    I noticed that the .doc file in the zip file was out-dated. Some people got confused by it. The zip file on my server is now updated.

    Note: Do NOT use the tutorial from me in the tutorial section about Highscores. It's the old one. I emailed the administrator with the question if he could update it a few weeks ago, but I guess he's busy.

    Anywayz, I hope the tutorial is still clear to all of you and you are still using it.. ^_^

    Ciao -Jeroen

  18. #18
    Flying on Herbal Tea
    Join Date
    Jun 2002
    Location
    Scotland
    Posts
    469
    Bump-ah-dee-bump

    great thanx a lot = )

    bumping aswell, iv seen 4 mentions o highscore tables in the last 2 weeks = )

  19. #19
    I just learned what "bumping" means. Great job on this php!

  20. #20
    Flash Developer on a break
    Join Date
    Jun 2001
    Location
    The Netherlands
    Posts
    1,370
    UnderTheSun - You are still experiencing problems? If you do, what version of PHP are you using?

    You can check with making a file with only <?php phpinfo(); ?> in it.

    | "Keep Flashing!"-Jeroen
    PHP multiplayer? Check this thread: PHPgateway

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center