High score in simple flash game

Hello
I wrote a simple shot em up flash game and assigned a
variable for score. Now I want to be able to ask players to enter
their name and record the highest score.
As you can guess I'm a relative newbie, still ploughing my
way through action script tutorials. If there is a quick solution
I'd appecreciate a response. I just don't know where to get
started.
Thanks

This is an old technique but it works great using php:
http://www.flashkit.com/tutorials/Games/High-sco-Glen_Rho-657/index.php

Similar Messages

  • Super Simple Flash Game Tutorials?

    I'm looking for some super simple flash game tutorials that students can complete in about an hour.  I don't want a lot of actionscript, but some is necessary and that's fine.  Drop any links you may know of or any book titles.  I don't mind buying a book if it is what I'm looking for.  Flash CS5

    This is an old technique but it works great using php:
    http://www.flashkit.com/tutorials/Games/High-sco-Glen_Rho-657/index.php

  • Where can I buy the code or buy the book to make a simple flash game?

    I need to make or buy a template for a simple flash game for a clients website. It has to be legit to buy. It is about 5 pages long. You are asked a question, you select a radio button for the answer to the question, it compiles all your answers and gives you a result.
    I know flash pretty well but ccording to budget and time.it is best not to have to experiment.
    Let me know, I appreciate the imput!

    http://activeden.net/searches?term=quiz&type=files

  • How can i record a name a score in a flash game and write down in a soreboard?

    Hi. I wrote down the summary of my project so that you can
    understand and answer me more easily:
    I have to build an application (a little flash game) in which
    I record the number of clicks. I want the player to choose a nick
    at the beginning and when he finishes one or all the four choices
    of target, i want the application to write his nick and final score
    in a database for displaying in a scoreboard (hall of fame). All
    the new entries should be sorted according to the score. If the
    same nick appears again, it's final score will be modified in the
    scoreboard only if is higher then the previous.
    I was thinking of creating a variable for the name that is
    chosen at the beginning and a variable for the score that is
    recorded. When the player finishes the game i want the application
    to write his data in the database, and then to display the
    scoreboard (let's say top 10 players in the database from the
    highest to the lowest score).
    I never did this before so i am asking what database shoud i
    use? I need a programmer to create one for me? Or can flash
    generate the database?
    Is the variable the good way or should I aproach the problem
    by other means? And if a programmer creates a database in MySql is
    that good or he should convert it to XML, or Flash generates the
    XML?
    Thank you.
    Mark this message as the answer.

    The bottom line is you cannot write to a file (database or
    XML files) directly from flash.
    I have done a number of projects where I needed to have
    access to an XML source or a database. In these cases I had to
    create server side script. I have done them in .NET, PHP ASP.
    The only option you have is to use the Flash's Shared Object.
    This does not store the data indefinatly and has a limited size
    (100K). Let me know if you need further info.
    With regards to using a variables depends on how you are
    writing your game. If you are creating classes in ActionScript then
    all the data can be stored within the class members. For example
    you could have a Player Class and store all the player related
    information in that class until the game is over. On the other hand
    you can just use varibles to keep things simple.

  • Please help me with a simple flash game problem

    I am trying to learn how to make flash games with Adobe flash 5.5. I am doing a tutorial from a book and am stuck.
    The game is called concentration and you are suppose to match 2 tiles of the same shape. there are 10 shape tiles
    and 1 question mark tile. These tiles are held in an array. 20 tiles are suppose to be displayed 5 to a row with 4 rows
    and the question mark is suppose to be up on all 20. My problem is I get a blank screen when I test the movie. I
    think the code is good but I beleive I have not uploaded the tiles right. I did upload the 11 tiles to the library and have
    those 11 tiles and tile_movieclip in the library. Here is the code:
    package {
    // importing classes
    import flash.display.Sprite;
    // end of importing classes
    public class Main extends Sprite {
    public function Main() {
    // variables and constants
    const NUMBER_OF_TILES:uint=20;
    const TILES_PER_ROW:uint=5;
    var tiles:Array=new Array();
    var tile:tile_movieclip;
    // end of variables and constants
    // tiles creation loop
    for (var i:uint=0; i<NUMBER_OF_TILES; i++) {
    tiles.push(Math.floor(i/2));
    trace("My tiles: "+tiles);
    // end of tiles creation loop
    // shuffling loop
    var swap,tmp:uint;
    for (i=NUMBER_OF_TILES-1; i>0; i--) {
    swap=Math.floor(Math.random()*i);
    tmp=tiles[i];
    tiles[i]=tiles[swap];
    tiles[swap]=tmp;
    trace("My shuffled tiles: "+tiles);
    // end of shuffling loop
    // tile placing loop
    for (i=0; i<NUMBER_OF_TILES; i++) {
    tile=new tile_movieclip();
    addChild(tile);
    tile.cardType=tiles[i];
    tile.x=5+(tile.width+5)*(i%TILES_PER_ROW);
    tile.y=5+(tile.height+5)*(Math.floor(i/TILES_PER_ROW));
    tile.gotoAndStop(NUMBER_OF_TILES/2+1);
    // end of tile placing loop
    Can someone please explain to me what I am suppose to do to make the this work? I beleive the problem is it doesnt know where the tiles are.
    Thanks.

    To create the tiles, draw 10 distinct shapes in the first 10 frames of your symbol, and
    the back of the tile in the 11th frame. You are free to draw them as you want, but I suggest you make them as 90 pixels squares with registration point (starting x and y position) at 0, because these are the properties of the tiles used in this chapter's
    examples. At least, they should all be the same size.
    It didnt say put in a library. It is saying to draw them in frames of symbol but it didnt walk me through that. Can you guide me through this? I also was looking at how to add the link identifier but it said I need a popup window but I cant see one. I thought that was done
    when I went to insert new symbol. It said something about actionscript linkage. I am familliar with perl, java and c++ so I can follow the code so far but I dont have much understanding of the flash interface. I made the 10 shape tiles and the 1 question mark tile
    in paint. They are .jpeg images.

  • Flash Game High Scores Board

    Hello everyone,
    I know this is a subject that gets covered a lot as i have found a ton of tutorials that show a million dfferent ways to create a high scores board on a flash game.  So i decided to go out on a limb and pick a tutorial out to try.  Well I have now tried 3 different ones and have yet to get a working high scores board with my game.
    http://www.flashkit.com/tutorials/Games/How_to_c-Nick_Kuh-771/index.php
    That is the link to the most recent attempts to creat my high scores board.  When i finished everything the way the tutorial said it seemed like everything would work and then it just didnt.  After spending oh about 40 plus hours trying to make a high scores board i am getting very frustrated.  My game is scripted in AS2 and i have access to mysql and can set up unlimited databases.
    Can anyone please help me by sending an easy to follow tutorial that will work with AS2?  I would just like any kind of help right now as I feel ALL of my valid ideas have been ehausted.  Thanks in advance to anyone that can help!
    kapelskic

    Okay not a problem.
    This is my code on the very first frame of the game that initializes the the highscores.php script
    command = "init";
    _root.loadVariables("highscores.php?"+int(Math.random()*100000), "POST");
    This is the code that I have on a submit button, next to the input text box where the user enters their name for the scoreboard.
    on (release) {
    if(name ne ""){
    command = "update";
    _root.loadVariables("highscores.php?"+int(Math.random()*100000), "POST");
    gotoAndStop ("highScores");
    In every place the code says _root. I have also tried this. and neither of them work.  I have also tried a million other things.  So far the game plays through, goes to the game over screen where it asks for a user name and tells them their score.  Then once they press submit the game goes to the highScores screen but the name and score are not there.  The high scores screen cosists of 2 dynamic text fields one named "players" and one named "scores".  I hope this helps because I spent another 5 or so hours after my initial posts trying more tutorials with still no luck.  (the problem i am having is that i am new to flash, however not to PHP)
    kapelskic

  • AS3 Air High Score Help

    Hello everyone, i just came here to ask how to add a high score feature in as3 for android and ios. I want it to display on the main menu of the game. Heres my main file (game.as). I am wondering how i would implement it into that? (as you can see i have tried but failed...) please point me in the right direction on this one I want it to display in a dynamic text field called "bestScore" in a movieclip called "HighScore" the instance name of HighScore is bestScore so idk lol. Im new to as3... My score is in a movieclip called "Score" and the dynamic text field is "scoreDisplay" and the instance name is "gameScore" If that helps. Heres my game.as:
    [as]
    package
              import flash.display.MovieClip;
              import flash.utils.Timer;
              import flash.events.TimerEvent;
              import flash.ui.Mouse;
              import flash.events.KeyboardEvent;
              import flash.ui.Keyboard;
              import flash.events.Event;
              import flash.media.SoundChannel;
              import flash.net.SharedObject;
              public class Game extends MovieClip
                        static var ship:MovieClip;
                        static var healthMeter:HealthMeter;
                        static var score:Score;
                        static var highScore:HighScore;
                        static var enemyShipTimer:Timer;
                        static var gameOverMenu:GameOverMenu;
                        static var startMenu:StartMenu;
                        static var startButton:StartButton;
                        static var pauseButton:PauseButton;
                        static var playButton:PlayButton;
                        static var mainMenuButton:MainMenuButton;
                        public var currentValue:Number;
                        public var sharedObject:SharedObject;
                        public function Game()
                                  Key.initialize(stage);
                                  ship = new Ship();
                                  healthMeter = new HealthMeter();
                                  var score:Score = new Score();
                                  var highScore:HighScore = new HighScore();
                                  addChild(score);
                                  addChild(highScore);
                                  gameScore.visible = false;
                                  bestScore.visible = true;
                                  healthMeter.x = 2.5;
                                  healthMeter.y = 576;
                                  gameOverMenu = new GameOverMenu();
                                  gameOverMenu.x = 217;
                                  gameOverMenu.y = 244;
                                  addChild(gameOverMenu);
                                  gameOverMenu.visible = false;
                                  gameOverMenu.playAgainButton.addEventListener("mouseDown", newGame);
                                  startMenu = new StartMenu();
                                  mainMenuButton = new MainMenuButton();
                                  startButton = new StartButton();
                                  startMenu.x = 151;
                                  startMenu.y = 111;
                                  startButton.x = 93;
                                  startButton.y = 426;
                                  mainMenuButton.x = 656;
                                  mainMenuButton.y = 483;
                                  addChild(mainMenuButton);
                                  mainMenuButton.visible = false;
                                  stage.addChildAt(startMenu, 0);
                                  addChild(startButton);
                                  startMenu.visible = true;
                                  startButton.visible = true;
                                  startMenu.visible = true;
                                  startButton.addEventListener("mouseDown", newGame);
                                  mainMenuButton.addEventListener("mouseDown", mainMenu);
                                  pauseButton = new PauseButton();
                                  pauseButton.x = 896;
                                  pauseButton.y = 63;
                                  pauseButton.addEventListener("mouseDown", PauseGame);
                                  playButton = new PlayButton();
                                  playButton.x = 896;
                                  playButton.y = 63;
                                  addChild(playButton);
                                  playButton.visible = false;
                                  playButton.addEventListener("mouseDown", PlayGame);
                        static function gameOver()
                                  mainMenuButton.visible = true;
                                  healthMeter.visible = false;
                                  pauseButton.visible = false;
                                  gameOverMenu.visible = true;
                                  enemyShipTimer.stop();
                                  for (var i in EnemyShip.list)
                                            EnemyShip.list[i].kill();
                                  ship.takeDamage(-ship.maxHealth);
                        function newGame(e:Event)
                                  addEventListener(Event.DEACTIVATE, PauseGame);
                                  bestScore.visible = false;
                                  gameScore.visible = true;
                                  addChild(pauseButton);
                                  addChild(healthMeter);
                                  addChild(mainMenuButton);
                                  enemyShipTimer = new Timer(750);
                                  enemyShipTimer.addEventListener("timer", sendEnemy);
                                  addChild(ship);
                                  healthMeter.visible = true;
                                  startMenu.visible = false;
                                  mainMenuButton.visible = false;
                                  startButton.visible = false;
                                  healthMeter.visible = true;
                                  pauseButton.visible = true;
                                  playButton.visible = false;
                                  gameOverMenu.visible = false;
                                  ship.visible = true;
                                  ship.x = 367;
                                  ship.y = 542;
                                  enemyShipTimer.start();
                                  currentValue = 0;
                                  updateDisplay();
                        function mainMenu(e:Event)
                                  removeEventListener(Event.DEACTIVATE, PauseGame);
                                  bestScore.visible = true;
                                  gameScore.visible = false;
                                  removeChild(mainMenuButton);
                                  removeChild(ship);
                                  healthMeter.visible = false;
                                  startMenu.visible = true;
                                  mainMenuButton.visible = false;
                                  startButton.visible = true;
                                  healthMeter.visible = false;
                                  pauseButton.visible = false;
                                  playButton.visible = false;
                                  ship.takeDamage(ship.maxHealth);
                                  gameOverMenu.visible = false;
                        function PauseGame(e:Event)
                                  enemyShipTimer.removeEventListener("timer", sendEnemy);
                                  stage.frameRate = 0;//
                                  pauseButton.visible = false;
                                  playButton.visible = true;
                        function PlayGame(e:Event)
                                  enemyShipTimer.addEventListener("timer", sendEnemy);
                                  stage.frameRate = 30;//
                                  pauseButton.visible = true;
                                  playButton.visible = false;
                        public function Counter()
                                  reset();
                        function sendEnemy(e:Event)
                                  var enemy = new EnemyShip();
                                  stage.addChildAt(enemy, 0);
                                  addToValue(1);
                        function addToValue( amountToAdd:Number ):void
                                  currentValue = currentValue + amountToAdd;
                                  updateDisplay();
                        function setValue( amount:Number ):void
                                  currentValue = amount;
                                  updateDisplay();
                        function reset():void
                                  currentValue = 0;
                                  updateDisplay();
                        function updateDisplay():void
                                  gameScore.scoreDisplay.text = currentValue.toString();
                        function getFinalScore():Number
                                  return gameScore.currentValue;
                        public function GameOverScreen()
                                  sharedObject = SharedObject.getLocal("natdScores");
                        public function setFinalScore( scoreValue:Number ):void
                                  gameScore.text = scoreValue.toString();
                                  if (sharedObject.data.bestScore == null)
                                            sharedObject.data.bestScore = scoreValue;
                                  else if ( scoreValue > sharedObject.data.bestScore )
                                            sharedObject.data.bestScore = scoreValue;
                                  bestScore.text = sharedObject.data.bestScore.toString();
                                  sharedObject.flush();
    [/as]
    Thanks in advance
    -Ben

    hello again, i added that code to the updatedisplay function with the currentValue.toString(); because putting a number there would achieve nothing here, and it works, but it doesnt save the highest score. whatever score is the last score it puts it there, becoming like a last score than a high score feature. heres my game.as again with your help
    [as]
    package
              import flash.display.MovieClip;
              import flash.utils.Timer;
              import flash.events.TimerEvent;
              import flash.ui.Mouse;
              import flash.events.KeyboardEvent;
              import flash.ui.Keyboard;
              import flash.events.Event;
              import flash.media.SoundChannel;
              import flash.net.SharedObject;
              import flash.text.TextField;
              public class Game extends MovieClip
                        static var ship:MovieClip;
                        static var healthMeter:HealthMeter;
                        static var score:Score;
                        static var highScore:HighScore;
                        static var enemyShipTimer:Timer;
                        static var gameOverMenu:GameOverMenu;
                        static var startMenu:StartMenu;
                        static var startButton:StartButton;
                        static var pauseButton:PauseButton;
                        static var playButton:PlayButton;
                        static var mainMenuButton:MainMenuButton;
                        public var currentValue:Number;
                        public var sharedObject:SharedObject;
                        public function Game()
                                  Key.initialize(stage);
                                  ship = new Ship();
                                  healthMeter = new HealthMeter();
                                  var score:Score = new Score();
                                  var highScore:HighScore = new HighScore();
                                  addChild(score);
                                  addChild(highScore);
                                  gameScore.visible = false;
                                  bestScore.visible = true;
                                  healthMeter.x = 2.5;
                                  healthMeter.y = 576;
                                  gameOverMenu = new GameOverMenu();
                                  gameOverMenu.x = 217;
                                  gameOverMenu.y = 244;
                                  addChild(gameOverMenu);
                                  gameOverMenu.visible = false;
                                  gameOverMenu.playAgainButton.addEventListener("mouseDown", newGame);
                                  startMenu = new StartMenu();
                                  mainMenuButton = new MainMenuButton();
                                  startButton = new StartButton();
                                  startMenu.x = 151;
                                  startMenu.y = 111;
                                  startButton.x = 93;
                                  startButton.y = 426;
                                  mainMenuButton.x = 656;
                                  mainMenuButton.y = 483;
                                  addChild(mainMenuButton);
                                  mainMenuButton.visible = false;
                                  stage.addChildAt(startMenu, 0);
                                  addChild(startButton);
                                  startMenu.visible = true;
                                  startButton.visible = true;
                                  startMenu.visible = true;
                                  startButton.addEventListener("mouseDown", newGame);
                                  mainMenuButton.addEventListener("mouseDown", mainMenu);
                                  pauseButton = new PauseButton();
                                  pauseButton.x = 896;
                                  pauseButton.y = 63;
                                  pauseButton.addEventListener("mouseDown", PauseGame);
                                  playButton = new PlayButton();
                                  playButton.x = 896;
                                  playButton.y = 63;
                                  addChild(playButton);
                                  playButton.visible = false;
                                  playButton.addEventListener("mouseDown", PlayGame);
                        static function gameOver()
                                  mainMenuButton.visible = true;
                                  healthMeter.visible = false;
                                  pauseButton.visible = false;
                                  gameOverMenu.visible = true;
                                  enemyShipTimer.stop();
                                  for (var i in EnemyShip.list)
                                            EnemyShip.list[i].kill();
                                  ship.takeDamage(-ship.maxHealth);
                        function newGame(e:Event)
                                  addEventListener(Event.DEACTIVATE, PauseGame);
                                  bestScore.visible = false;
                                  gameScore.visible = true;
                                  addChild(pauseButton);
                                  addChild(healthMeter);
                                  addChild(mainMenuButton);
                                  enemyShipTimer = new Timer(750);
                                  enemyShipTimer.addEventListener("timer", sendEnemy);
                                  addChild(ship);
                                  healthMeter.visible = true;
                                  startMenu.visible = false;
                                  mainMenuButton.visible = false;
                                  startButton.visible = false;
                                  healthMeter.visible = true;
                                  pauseButton.visible = true;
                                  playButton.visible = false;
                                  gameOverMenu.visible = false;
                                  ship.visible = true;
                                  ship.x = 367;
                                  ship.y = 542;
                                  enemyShipTimer.start();
                                  currentValue = 0;
                                  updateDisplay();
                        function mainMenu(e:Event)
                                  removeEventListener(Event.DEACTIVATE, PauseGame);
                                  bestScore.visible = true;
                                  gameScore.visible = false;
                                  removeChild(mainMenuButton);
                                  removeChild(ship);
                                  healthMeter.visible = false;
                                  startMenu.visible = true;
                                  mainMenuButton.visible = false;
                                  startButton.visible = true;
                                  healthMeter.visible = false;
                                  pauseButton.visible = false;
                                  playButton.visible = false;
                                  ship.takeDamage(ship.maxHealth);
                                  gameOverMenu.visible = false;
                        function PauseGame(e:Event)
                                  enemyShipTimer.removeEventListener("timer", sendEnemy);
                                  stage.frameRate = 0;//
                                  pauseButton.visible = false;
                                  playButton.visible = true;
                        function PlayGame(e:Event)
                                  enemyShipTimer.addEventListener("timer", sendEnemy);
                                  stage.frameRate = 30;//
                                  pauseButton.visible = true;
                                  playButton.visible = false;
                        public function Counter()
                                  reset();
                        function sendEnemy(e:Event)
                                  var enemy = new EnemyShip();
                                  stage.addChildAt(enemy, 0);
                                  addToValue(1);
                        function addToValue( amountToAdd:Number ):void
                                  currentValue = currentValue + amountToAdd;
                                  updateDisplay();
                        function setValue( amount:Number ):void
                                  currentValue = amount;
                                  updateDisplay();
                        function reset():void
                                  currentValue = 0;
                                  updateDisplay();
                        public function updateDisplay():void
                                  TextField(gameScore.getChildByName("scoreDisplay")).text = currentValue.toString();
                                  TextField(bestScore.getChildByName("bestScore")).text = currentValue.toString();
                        function getFinalScore()
                                  return gameScore.currentValue;
                        public function GameOverScreen()
                                  sharedObject = SharedObject.getLocal("natdScores");
                        public function setFinalScore( scoreValue:Number ):void
                                  gameScore.text = scoreValue.toString();
                                  if (sharedObject.data.bestScore == null)
                                            sharedObject.data.bestScore = scoreValue;
                                  else if ( scoreValue > sharedObject.data.bestScore )
                                            sharedObject.data.bestScore = scoreValue;
                                  bestScore.text = sharedObject.data.bestScore.toString();
                                  sharedObject.flush();
    [/as]

  • Help needed with creating Flash game

    Hello,
    I need to create Flash educational/quiz game for one of my clients. It would be based on concept like these ones for example:
    Example 1
    http://go.ucsusa.org/game/
    Example 2
    http://www.zdravlje.hr/igre/stop-aids/
    Note: when you open this link you will see two text boxs which you first must fill. On the left side text box "Upišite ime" means "Type your name" and right one "Upišite godinu svog rođenja" means "Year of birth"
    What is interesting about this type of games is that they are classic games (for example game Labirint where you have to find way out), but during play pop-up questions starts to appear to test end user knowledge abot certain topic (in example 2 topic is about AIDS/HIV). In case of my client, topic is about Eco environment.
    Here is where my trouble starts;) : I found many useful free tutorials how to create simple flash game (most interesting example I found is this one http://www.strille.net/tutorials/snake/index.php)  BUT I dont know how make that system of popup questions appear during game similar to Example 1 and Example 2?
    Any help is appreciated and thanks in advance for promt reply.
    Greetings,
    Adnan

    Update: I have just read all instructions in Snake tutorial which helped be better realize how Snake game works.
    a) This is what I plan to realize for my client:
    1. Snake game which end users will play and during play pop-up/quiz quesions will appear on topic Eco environment;
    2. For example when end user earns 50 points he must answer some of the random questions like "Q:How many ton of waste are produced by US livestock each year" with three answers A1: "1 milion" A2: "1 bilion" A3: "2 bilion" and after user scores 100 points then another question pops up and so on. This is all true if all answers are correct but in case he answer some question wrong than game can start from begining or another solution could be he looses -50 or -100 points.
    3. At the end, user which gains most points wins.
    b) This is what I have done till now:
    I have this file http://www.strille.net/tutorials/snake/snakeGameWithHighscore.zip which I partly understand how it works with my Flash knowladge.
    All functions and main game engine is in layer code:
    "// Snake Game by Strille, 2004, www.strille.net
    blockSize = 8;   // the block width/height in number of pixels
    gameHeight = 30; // the game height in number of blocks
    gameWidth  = 45; // the game width in number of blocks
    replaySpeed = 1;
    SNAKE_BLOCK = 1; // holds the number used to mark snake blocks in the map
    xVelocity = [-1, 0, 1, 0]; // x velocity when moving left, up, right, down
    yVelocity = [0, -1, 0, 1]; // y velocity when moving left, up, right, down
    keyListener = new Object(); // key listener
    keyListener.onKeyDown = function() {
        var keyCode = Key.getCode(); // get key code
        if (keyCode > 36 && keyCode < 41) { // arrow keys pressed (37 = left, 38 = up, 39 = right, 40 = down)...
            if (playRec) {
                if (keyCode == 37 && replaySpeed > 1) {
                    replaySpeed--;
                } else if (keyCode == 39 && replaySpeed < 10) {
                    replaySpeed++;
            } else if (game.onEnterFrame != undefined) { // only allow moves if the game is running, and is not paused
                if (keyCode-37 != turnQueue[0]) { // ...and it's different from the last key pressed
                    turnQueue.unshift(keyCode-37); // save the key (or rather direction) in the turnQueue
        } else if (keyCode == 32) { // start the game if it's not started (32 = SPACE)
            if (!gameRunning || playRec) {
                startGame(false);
        } else if (keyCode == 80) { // pause/unpause (80 = 'P')
            if (gameRunning && !playRec) {
                if (game.onEnterFrame) { // pause
                    delete game.onEnterFrame; // remove main loop
                    textMC.gotoAndStop("paused");
                } else { // exit pause mode
                    game.onEnterFrame = main; // start main loop
                    textMC.gotoAndStop("hide");
    Key.addListener(keyListener);
    function startGame(pRec) {
        x = int(gameWidth/2); // x start position in the middle
        y = gameHeight-2;     // y start position near the bottom
        map = new Array(); // create an array to store food and snake
        for (var n=0;n<gameWidth;n++) { // make map a 2 dimensional array
            map[n] = new Array();
        turnQueue = new Array(); // a queue to store key presses (so that x number of key presses during one frame are spread over x number of frames)
        game.createEmptyMovieClip("food", 1); // create MC to store the food
        game.createEmptyMovieClip("s", 2); // create MC to store the snake
        scoreTextField.text = "Score: 0"; // type out score info
        foodCounter = 0; // keeps track of the number of food movie clips
        snakeBlockCounter = 0; // keeps track of the snake blocks, increased on every frame
        currentDirection = 1; // holds the direction of movement (0 = left, 1 = up, 2 = right, 3 = down)
        snakeEraseCounter = -1; // increased on every frame, erases the snake tail (setting this to -3 will result in a 3 block long snake at the beginning)
        score = 0; // keeps track of the score
        ticks = lastRec = 0;
        recPos = recFoodPos = 0;
        playRec = pRec;
        if (!playRec) {
            textMC.gotoAndStop("hide"); // make sure no text is visible (like "game over ")
            highscores.enterHighscoreMC._visible = false;
            statusTextField.text = "";
            recTurn = "";
            recFrame = "";
            recFood = "";
            game.onEnterFrame = main; // start the main loop
        } else {
            if (loadedRecordingNumber != -1) {
                var n = getLoadedRecordingNumberHighscorePos(loadedRecordingNumber);
                statusTextField.text = "Viewing " + highscores[n].name.text + "'s game (score " + highscores[n].score.text + ")";
            } else {
                statusTextField.text = "Viewing your game";
            game.onEnterFrame = replayMain; // start the main loop
        placeFood("new"); // place a new food block
        gameRunning = true; // flag telling if the game is running. If true it does not necessarily mean that main is called (the game could be paused)
    function main() { // called on every frame if the game is running and it's not paused
        if (playRec) {
            if (ticks == lastRec+parseInt(recFrame.charAt(recPos*2)+recFrame.charAt(recPos*2+1), 36)) {
                currentDirection = parseInt(recTurn.charAt(recPos));
                lastRec = ticks;
                recPos++;
        } else if (turnQueue.length) { // if we have a turn to perform...
            var dir = turnQueue.pop(); // ...pick the next turn in the queue...
            if (dir % 2 != currentDirection % 2) { // not a 180 degree turn (annoying to be able to turn into the snake with one key press)
                currentDirection = dir; // change current direction to the new value
                recTurn += dir;
                var fn = ticks-lastRec;
                if (fn < 36) {
                    recFrame += " "+new Number(fn).toString(36);
                } else {
                    recFrame += new Number(fn).toString(36);
                lastRec = ticks;
        x += xVelocity[currentDirection]; // move the snake position in x
        y += yVelocity[currentDirection]; // move the snake position in y
        if (map[x][y] != SNAKE_BLOCK && x > -1 && x < gameWidth && y > -1 && y < gameHeight) { // make sure we are not hitting the snake or leaving the game area
            game.s.attachMovie("snakeMC", snakeBlockCounter, snakeBlockCounter, {_x: x*blockSize, _y: y*blockSize}); // attach a snake block movie clip
            snakeBlockCounter++; // increase the snake counter
            if (map[x][y]) { // if it's a not a vacant block then there is a food block on the position
                score += 10; // add points to score
                scoreTextField.text = "Score: " + score; // type out score info
                snakeEraseCounter -= 5; // make the snake not remove the tail for five loops
                placeFood(map[x][y]); // place the food movie clip which is referenced in the map map[x][y]
            map[x][y] = SNAKE_BLOCK; // set current position to occupied
            var tailMC = game.s[snakeEraseCounter]; // get "last" MC according to snakeEraseCounter (may not exist)
            if (tailMC) { // if the snake block exists
                delete map[tailMC._x/blockSize][tailMC._y/blockSize]; // delete the value in the array m
                tailMC.removeMovieClip(); // delete the MC
            snakeEraseCounter++; // increase erase snake counter   
        } else { // GAME OVER if it is on a snake block or outside of the map
            if (playRec) {
                startGame(true);
            } else {
                gameOver();
            return;
        ticks++;
    function replayMain() {
        for (var n=0;n<replaySpeed;n++) {
            main();
    function gameOver() {
        textMC.gotoAndStop("gameOver"); // show "game over" text
        delete game.onEnterFrame; // quit looping main function
        gameRunning = false; // the game is no longer running
        enterHighscore();
    function placeFood(foodMC) {
        if (playRec) {
            var xFood = parseInt(recFood.charAt(recFoodPos*3)+recFood.charAt(recFoodPos*3+1), 36);
            var yFood = parseInt(recFood.charAt(recFoodPos*3+2), 36);
            recFoodPos++;
        } else {
            do {
                var xFood = random(gameWidth);
                var yFood = random(gameHeight);
            } while (map[xFood][yFood]); // keep picking a spot until it's a vacant spot (we don't want to place the food on a position occupied by the snake)
            if (xFood < 36) {
                recFood += " "+new Number(xFood).toString(36);
            } else {
                recFood += new Number(xFood).toString(36);
            recFood += new Number(yFood).toString(36);
        if (foodMC == "new") { // create a new food movie clip
            foodMC = game.food.attachMovie("foodMC", foodCounter, foodCounter);
            foodCounter++;
        foodMC._x = xFood*blockSize; // place the food
        foodMC._y = yFood*blockSize; // place the food
        map[xFood][yFood] = foodMC; // save a reference to this food movie clip in the map
    //- Highscore functions
    loadHighscores();
    enterHighscoreKeyListener = new Object();
    enterHighscoreKeyListener.onKeyDown = function() {
        if (Key.getCode() == Key.ENTER) {
            playerName = highscores.enterHighscoreMC.nameTextField.text;
            if (playerName == undefined || playerName == "") {
                playerName = "no name";
            saveHighscore();
            Key.removeListener(enterHighscoreKeyListener);
            Key.addListener(keyListener);
            highscores.enterHighscoreMC._visible = false;
            loadedRecordingNumber = -1;
            startGame(true);
    function enterHighscore() {
        if (score >= lowestHighscore) {
            highscores.enterHighscoreMC._visible = true;
            highscores.enterHighscoreMC.focus();
            Key.removeListener(keyListener);
            Key.addListener(enterHighscoreKeyListener);
        } else {
            loadedRecordingNumber = -1;
            startGame(true);
    function getLoadedRecordingNumberHighscorePos(num) {
        for (var n=0;n<10;n++) {
            if (num == highscores[n].recFile) {
                return n;
    function loadHighscores() {
        vars = new LoadVars();
        vars.onLoad = function(success) {
            for (var n=0;n<10;n++) {
                var mc = highscores.attachMovie("highscoreLine", n, n);
                mc._x = 5;
                mc._y = 5+n*12;
                mc.place.text = (n+1) + ".";
                mc.name.text = this["name"+n];
                mc.score.text = this["score"+n];
                mc.recFile = parseInt(this["recFile"+n]);
            lowestHighscore = parseInt(this.score9);
            if (!gameRunning) {
                loadRecording(random(10));
            delete this;
        if (this._url.indexOf("http") != -1) {
            vars.load("highscores.txt?" + new Date().getTime());
        } else {
            vars.load("highscores.txt");
    function loadRecording(num) {
        vars = new LoadVars();
        vars.onLoad = function(success) {
            if (success && this.recTurn.length) {
                recTurn = this.recTurn;
                recFrame = this.recFrame;
                recFood = this.recFood;
                startGame(true);
            } else {
                loadRecording((num+1)%10);
                return;
            delete this;
        loadedRecordingNumber = num;
        if (this._url.indexOf("http") != -1) {
            vars.load("rec"+loadedRecordingNumber+".txt?" + new Date().getTime());
        } else {
            vars.load("rec"+loadedRecordingNumber+".txt");
    function saveHighscore() {
        sendVars = new LoadVars();
        for (var n in _root) {
            if (_root[n] != sendVars) {
                sendVars[n] = _root[n];
        returnVars = new LoadVars();
        returnVars.onLoad = function() {
            if (this.status == "ok") {
                loadHighscoresInterval = setInterval(function() {
                    loadHighscores();
                    clearInterval(loadHighscoresInterval);
                }, 1000);
            delete sendVars;
            delete this;
        sendVars.sendAndLoad("enterHighscore.php", returnVars, "POST");
    function startClicked() {
        if (!gameRunning || playRec) {
            if (highscores.enterHighscoreMC._visible) {
                Key.removeListener(enterHighscoreKeyListener);
                Key.addListener(keyListener);
                highscores.enterHighscoreMC._visible = false;
            startGame(false);
    function viewGame(lineMC) {
        loadRecording(lineMC.recFile);
        statusTextField.text = "Loading " + lineMC.name.text + "'s game...";
    Now what is left to do is somehow to iclude educational quiz in this game/code. First idea that came to me is same thing Ned suggested: to create some unique movie clip which would contain all data/questions lined up but main problem for me is how to "trigger" that movie clip to play only AFTER end user clicks on "Start game" or SPACE to restart? Not sure how to solve this issue?

  • High Scores Board AS2

    Hello everyone,
    I know this is a subject that gets covered a lot as i have found a ton of tutorials that show a million dfferent ways to create a high scores board on a flash game.  So i decided to go out on a limb and pick a tutorial out to try.  Well I have now tried 3 different ones and have yet to get a working high scores board with my game.
    http://www.flashkit.com/tutorials/Games/How_to_c-Nick_Kuh-771/index.ph p
    That is the link to the most recent attempts to creat my high scores board.  When i finished everything the way the tutorial said it seemed like everything would work and then it just didnt.  After spending oh about 40 plus hours trying to make a high scores board i am getting very frustrated.  My game is scripted in AS2 and i have access to mysql and can set up unlimited databases.
    Can anyone please help me by sending an easy to follow tutorial that will work with AS2?  I would just like any kind of help right now as I feel ALL of my valid ideas have been ehausted.  Thanks in advance to anyone that can help!
    kapelskic

    Please don't cross post in these forums

  • High Score System

    Does anyone know a High score system out there thats compatible with flash/android dev
    Something similar to open openfeint.

    I think Jesse Freeman (http://active.tutsplus.com/author/jesse-freeman/) has done some work on high score system with his game. Not sure if he has posted anything yet on how or what he did.
    Chris Griffith

  • How can I make a high scores list?

    I've heard a lot of options. I've tried writing to a perl script, I've read about signing an applet (which seems needlessly complicated). I just would like to know what is the easiest way to save a list of 10 high scores for a game that I'm making? If anyone out there has tried this already any advice would be REALLY appreciated
    thanks!

    What I'm trying to do is make just a high scores list for the game as a whole. It will be one high scores list of 10 names/scores that will be there for the applet. I already have everything set up to read the scores and order the scores in the program, i just need to know what the best way to save them permanently for the next time they need to be used is. I have the scores saved in a string array and I could write all the code myself to get those strings set up in whatever format I may need. But I just need to know how to save them once the applet is closed.

  • High Score Table: Writing a Simple Text File with Flash and PHP

    I am having a problem getting Flash to work with PHP as I need Flash to read and write to a text file on a server to store simple name/score data for a games hi score table. I can read from the text file into Flash easily enough but also need to write to the file when a new high score is reached, so I need to use PHP to do that. I can send the data from flash to the php file via POST but so far it is not working. The PHP file is confirmed as working as I added an echo to the file which displayed a message so I  could check that the server was running PHP - the files were also uploaded to a remote server so I  could test them properly. Flash code is as follows:
    //php filewriter
    var myLV = new LoadVars();
    function sendData() {
    //sets up variable 'hsdata' to send to php
    myLV.hsdata = myText;
    myLV.send("hiscores.php");
    I believe this sends the variable 'myText' to the php file as a variable called 'hsdata' which I want the php file to write into a text file. The mytext variable is just a long string that has all the scores and names in the hiscore. OK, XML would be better way of doing this but for speed I just want to get basic functionality working, so storing a simple text sting is adequate for now. The PHP code that reads the Flash 'hsdata' variable and writes it to the text file 'scores.txt' follows:
    <?php
    //assigns to variable the data POSTed from flash
    $flashdata = $_POST["hsdata"];
    //file handler opens file and erases all contents with w arg
    $fh = fopen("scores.txt","w");
    //adds data to file
    fwrite ($fh,$flashdata);
    //closes file
    fclose ($fh);
    echo 'php file is working';
    ?>
    Any help with this would be greatly appreciated - once I can get php to write simple text files I should be ok. Thanks.

    Thanks for your help.
    I have got Flash working to a certain extent with PHP using loadVars but have been unable to get flash to receive a variable declared in PHP. Here's my Flash code:
    var outLV = new LoadVars();
    var inLV = new LoadVars();
    function sendData() {
    outLV.hsdata = "Hello from Flash";
    outLV.sendAndLoad("http://www.mysite.com/hiscores/test23.php",inLV,"post");
    inLV.onLoad = function(success) {
    if (success) {
      //sets dynamic text box to show variable sent from php
      statusTxt.text = phpmess;
    } else {
      statusTxt.text = "No Data Received";
    This works ok and the inLV.onLoad function reports that it is receiving data but does not display the variable received from PHP. The PHP file is like this:
    <?php
    $mytxt =$_POST['hsdata'];
    $myfile = "test23.txt";
    $fh = fopen($myfile,'w');
    //adds data to file
    fwrite($fh, $mytxt);
    //closes file
    fclose ($fh);
    $mess = "hello there from php";
    echo ("&phpmess=$mess&");
    ?>
    The PHP file is correctly receiving the hsdata from flash and writing it to a text file, but there seems to be a problem with the final part of the code which is intended to send a variable called 'phpmess' back to Flash, this is the string "hello there from php". How do I set up Flash and PHP so that PHP can send a variable back to Flash using echo? Really have tried everything but am totally baffled. Online tutorials have given numerous different syntax configurations for how the PHP file should be written which has really confused me - any help would be greatly appreciated.

  • Hosting a server for simple game related info, rankings, high scores, etc.

    I have a quick question about servers. I want to implement a ranking system for one of my games, the server would store player high scores and world rankings based on their score and perhaps other fairly easy stuff. Writing the server and communicating from
    it with the app is the easy part in my mind, ive done it numerious times for personal projects (Like a Raspberry PI based quadrocopter i wrote). My question is this. If i wrote the server where do i host it? How do people typically host their servers that
    are simple like this? Do they get a static ip address and host it from a extra computer in there homes? Im not talking about big corporations like microsoft that have large server centers, just individual developers like me.  Any thoughts?
    thank you for your time.

    Yes, the server  app runs on the machine it is hosted on.
    See http://azure.microsoft.com/en-us/documentation/services/mobile-services/ to get started with Azure Mobile Services.
    If you want to write a web service yourself from scratch you'll need to pick your technology and look for documentation there. It's off topic in this forum, but check out http://www.asp.net/get-started and the http://forums.asp.net/ forums for asp.net.
    --Rob

  • I'd like to hire someone to create a simple interactive game in director or flash

    I can do some simple things with lingo and actionscript, but I have been given the task to create an interactive game that will be interfaced through a touchscreen. This is beyond my scope and would like some advice on where to turn for help. I have (briefly) explored some of the sites that advertise this type of service and so far they expect a huge budget and very long development timeframe.
    I really am looking for some basic stuff, a timer, a kept (high) score, random placement of (objects), an interface to scroll left and right allowing a larger game area than the 1280x1024 the touchscreen allows, collecting semi-hidden objects, jigsaw-type assembly of objects on another background scene using only the "found" pieces, etc.
    I supply all graphic elements, and only need the programming - in such a way that I can change the graphics if necessary.
    I do have a budget, and could use some advice on who may be available at a reasonable cost to my client.
    Thank you,
    James Patrick
    - I am very flexible to make this more simple. I would appreciate advice as this is on the fast track.

    I've done this many times for a variety of clients, and specifically for touch-screen kiosks. The basic difference with the touch-screen is to go in mouse
    -show vs. mouse-hide mode, and to keep the buttons and controls big enough for fingers.I also use a hidden menu (or control panel) button in my kiosk applications, so the user can change settings easily without having to use a mouse/keyboard.
    I generally do the game development in Flash, but I use Director as a shell (import the Flash files into Director) for the purpose of checking system requirements (RAM, video codecs, etc) and other system controls, which of course can't be done in Flash. Director also has more capabilities in terms of deploying the application. I can send you some sample games I've developed over the years.
    I may be able to assist you on a temporary contact basis, although we'd have to discuss scope to determine if your needs are a match for my capabilites and schedule. Let me know how to contact you offline.
    Thanks.

  • Flash Game Submit Score Problem

    I need to modify the flash game Replay button as Submit button and to redirect to other page(gamescore.html) after clicking the Submit button. I am new to flash. I don't know how to modify the script. Please help me. Here is the total score display portion of the script where replay button is there:
    //Set the total score
                                        _totalScore = _distanceToCity + _distanceToCity * ((_obstacleCount - _obstacleHit)/_obstacleCount);
                                        _retry.score_txt.text = _totalScore.toString();
                                        _retry.distance_txt.selectable = false;
                                        _retry.time_txt.selectable = false;
                                        _retry.obstacles_txt.selectable = false;
                                        _retry.obstaclesHit_txt.selectable = false;
                                        _retry.score_txt.selectable = false;
                                        _retry.buttonMode = true;
                                        _retry.addEventListener(MouseEvent.MOUSE_UP, retry);
    //Retry function, removes all platforms and reinitializes all the game's values
    function retry(event:MouseEvent):void
                try
                            event.currentTarget.removeEventListener(MouseEvent.MOUSE_UP, retry);
                            removeChild(MovieClip(event.currentTarget));
                            initialization();
                catch(err:Error)
                            trace("catch error 1009 on retry");

    i'm surprised score ever reaches 500 because _root.score and
    score (in the context of that onEnterFrame handler are different.
    anyway, try:

Maybe you are looking for

  • ECC 6.0 EHP4 upgrade to EHP5 fails in MAIN_NEWBAS/XPRAS_AIMMRG

    from SAPehpi.log CURRENTPHASE MAIN_NEWBAS/XPRAS_AIMMRG ...started at 20110825140601 ...begin processing at 20110825140601 ..times self: 0.080000/0.150000 usr/sys, children 0.560000/0.450000 usr/sys. ..finished at 20110825140820 with status UNRESOLVED

  • Error updating patch: CS6, Log information below

    Running Windows 7 Enterprise x64 (Should I bother updating since it is a small update only?) 07/22/13 08:14:13:463 | [INFO] |  | OOBE | DE |  |  |  | 8064 | *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* 07/22/1

  • Eliminate Scriptlets in form radio

    I have a web form working great for the past year using Scriptlets and Bean in Tomcat 6.0.20. Now I would like to eliminate the Scriptlets and use EL instead. Please advise how I can get the below radio input to work with EL in my JSP. All my attempt

  • MacBook Pro Retina 13" Early 2013 Logicboard Failed

    i've just bought MBP retina for about 14days old and its logicboard already failed! As soon as it boot up to OSX, about 20sec-30sec it showed kernel panic warning or it just does not respond anything. i've already tried anything (PVRAM reset,SMC rese

  • Change pointer & filter

    hi, may i know what is the use of change pointer, filter in distribution model? thanks