Flash Game Movements

I need help with my game project. I used sprites to maken a
running animation, but i want that when i press left he goes left
en when i press right he goed right but when i do that he doesn t
stop running.
Here it is »»»»»
http://www.zshare.net/flash/6964541d6c8f9d/
So can anybody tell me what am I doing wrong ?????
So can anybody help me
Ty in advance =)

I will not download the .fla - maybe if you hosted the .swf I would view it.
to change frame use: gotoAndStop(<framenumber>);
(without the < >, just a number for the fram).
I recommend you use movieclips for buttons and place all code on the main timeline. For movieclips, give them an identifier name (bottom left int he properties box of the movieclip) then on the main timeline use:
movieclipName.onRelease = function(){
gotoAndStop(10);//change 10 to the frame you wish to go to. gotoAndPlay(10) plays from the frame.

Similar Messages

  • Snowman Flash game - move ojbects possible ?

    Hi everyone,
    Have you ever come across Flash games at Christmas time, where kids can build a snowman, by moving graphics around on the screen.....
    i.e. move the snow balls into place, add a carrot for the nose, move the eyes into place etc.
    something lke this:
    http://www.flash-game.net/game/1482/create-a-snowman.html
    All graphic elements are usually in one area of the game, and the kids just move them into place.  These are Flash games, and flash has the ability to do this,
    does anyone know if Flash Catalyst is capable of doing this also ?
    Thanks for any help everyone !

    Hi David,
    Currently, drag/drop interactions can't be created using Flash Catalyst alone.  But there are two ways you can leverage Flash Builder in combinaion with Flash Catalyst to build an app like this:
    Prototype the app in Catalyst, then import it into Builder and add the dragging behavior by writing some code.  Caveat: you won't be able to reopen the project in Catalyst after modifying it in Builder; to make more changes using Catalyst, you'll have to modify the older copy of the project and then use Builder to merge the updates into the new copy.
    The next versions of Catalyst and Builder, codenamed "Panini" and "Burrito," allow you to create custom behavior in Builder and then assign artwork to that behavior directly within Catalyst (and continue editing in Catalyst afterward).  Early preview releases of these products are available now if you want to try this.
    Hope that helps!
    - Peter

  • FireFox with adobe flash using a retina macbook pro under win 8.1 64 bit is lagging . when you move the mouse above any flash game / video

    Hi
    I asked this question again and i reported this bug , i am a computer engineer and i tested it with few macbook pro retina laptops , when u use win 8.1 64 bit or 32 bit and install adobe flash under firefox try to play any game in facebook , view video on youtube or use any FLASH video and move the mouse above the screen of the flash game / video / etc , the screen will lag alot .
    under chrome this problem doesnt exist but the screen is blurry in chrome when using retina screen thats why firefox is better , but the problem is annoying .
    i tried to disable hardware acceleration as you suggested still the same problem

    Hi thesoulkeeper,
    Do you have the bug number? We can try needsinfo to ask for some help.

  • Best way to embed an Mov file into interactive flash game?

    Hey,
    just a quick query. I'm creating an interactive flash game for a university project. It's along the lines of Guitar Hero, Tap Tap Revolution, Boom Boom Rocket etc..
    At the moment the game comprises of streaks of notes generated by Actionscript which the user much hit the corresponding key when notes are in the receptor. The background at the moment is an audio spectrum analyser created using AS based on the music playing.
    I want to add loop movie file as the very background of the stage and was just wondering what was the best way to place it there with the least ammount of overheads. At the moment I have it in a child movie clip placed on the stage, in which I use File -> Import and embeded the FLV file into the time line. This works, however lags out quite badly.
    Any help would be appriciated.
    Thanks in advance,
    John Minns

    Have you tried this method?
    1. Save as new file.
    2. With your usual color management preferences selected, run Xtras>Color>'Name all colors'.
    3. In color swatches list, select all colors. From swatches pop-up menu 'Make RGB'.
    4. In Preferences>Color, set color management settings to 'None'. The RGB colors should look about the same as they did with color management on.
    Now you should be able to export to Flash with RGB colors that look quite close to your CMYK version of the file.
    This should work the same in FH9 or FHMX. I hope it does the trick for you.

  • 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-skeeball

    I need to create a flash version of the game skeeball. I've
    never done a flash game before and don't know where to start. I've
    found several tutorials and stuff on games, but none of them seem
    to fit the game of skeeball. Does anyone know any good tutorials or
    have any suggestions how to set this up?? I was thinking random
    movie clips of the ball going into one of the 8 holes, but I wanted
    something more realistic. Please any help would be greatly
    appreciated. Thank you for your time and patience.

    Do I know the answer - nope. But that is the challenge of
    making a Flash game, coming up with the ideas on how to make it
    work. When I created my first game I didn't know jack squat about
    using Flash. I basically came up with the concept, then figured out
    how to do each part step by step until it all came together. So,
    think about how you want the game to work, and don't worry about
    the "how to do it" part.
    Also, you might want to think of an original game, or
    something that hasn't been done before:
    http://www.candystand.com/play.do?id=17832
    Good luck!

  • Flash Game Button Rename

    I need to rename the replay button as Submit button in the flash game. I am new to flash and doesn't know how to do this? I am using Flash CS5 trial version and Actionscript 3. All game components and interfaces are displayed in the library list as Movie Clip. One movie clip named MC_replay has total score display and replay button. I want to rename this button. I selected and double-clicked this movie clip, it appeared on the main screen. I right clicked the button and found no edit options. If I double click, dots are appearing on the text. How to solve this problem. Can any one help me?

    What do you mean ?
    Do you want to change the text to Submit ? User will see "Submit" instead of "Replay"
    or
    Do you want to change the instance name (for AS coding) ?
    I guess you want to change just the text.
    Double-click , find the text , select it , delete it and add a Text object.
    Better you upload your fla file and I 'll check it.

  • Flash Games-Custom Cursors

    If there is a custom mouse cursor in a flash game, my cpu
    usage is getting up to 80% (flashplayer usage). Like in cake mania
    game flash. My mouse cursor is always shaking. Also It effects
    other pages on browser (ie and ff).
    scrsht:
    http://img261.imageshack.us/img261/9200/cursordz4.jpg
    sample flash file:
    http://www.oyunola.com/oyunlar/beceri/cakemania.swf
    -My problem?
    -Game designer problem?
    -Or flash player problem?
    thnx

    Chris, thanks for the suggestion
    I went through this and here’s what happened:
    -          I do not have Realplayer
    -          When I went into protected mode (forced to create a new profile) the problem still occurred
    However, I wonder if I did something wrong --
    Is there a way to verify that Firefox is actually in protected mode? It doesn’t look any different, and even has my home page!
    I did learn that the problem is intermittent – some games (maybe smaller ones? Not sure how to tell) load ok
    One that works for me: http://miniarcadebox.com/2012/09/small-safes-house-escape-2/
    One that doesn’t: http://www.melting-mindz.com/turtle_island_escape.php
    Right click gives message “Movie not loaded”

  • Flash game error in Chrome

    when I play flash games and moves it lags immensively I am using Windows vista and google chrome 21.0.1180.60. If I play on IE it works perfectly. I have got a video of it just follow this linkhttp://www.sendspace.com/file/21vkak .You can find the game following this linkhttp://gratisspil.dk/onlineGame/games/play.php?id=4449#commentsPaginator=1.
    I have tried everything on the support page.

    This forum software is very tricky; updates to forum posts sometimes need to be done three or four times until it "takes".  I have been able to update your original post.
    Now that it is actually readable, I will go and have a look at it.

  • How to Make Multiplayer TCP Flash Game?

    I have a game in the works, and though I got the UDP to work perfectly, I sadly later found out that that is simply just a lossy protocol. There's apparently (as far as my knowledge goes) nothing you can do to make it resend data if the data was not received successfully by the recipient.
    So, I was wondering how to use TCP? I've heard it's possible, but I can't seem to find a single tutorial or any information anywhere on how to do it. I found on Adobe's site socket connections, and though I got the server to connect (I think), I have no clue how to send data to it, how to get other clients to connect to it, etc. Any help?
    This is the script I've been using, and though it does connect... that's basically all it does, I don't know where to go from here...
    package
        import flash.display.Sprite;
        import flash.events.EventDispatcher;
        import flash.events.Event;
        import flash.events.*;
        import flash.events.IOErrorEvent;
        import flash.events.ProgressEvent;
        import flash.events.ServerSocketConnectEvent;
        import flash.net.ServerSocket;
        import flash.net.Socket;
        public class TCP extends Sprite
            private var serverSocket:ServerSocket;
            private var clientSockets:Array = new Array();
            public function TCP()
                try
                    // Create the server socket
                    serverSocket = new ServerSocket();
                    // Add the event listener
                    serverSocket.addEventListener( Event.CONNECT, connectHandler );
                    serverSocket.addEventListener( Event.CLOSE, onClose );
                    // Bind to local port 8087
                    serverSocket.bind( 8087, "127.0.0.1" );
                    // Listen for connections
                    serverSocket.listen();
                    trace( "Listening on " + serverSocket.localPort );
                catch(e:SecurityError)
                    trace(e);
            public function connectHandler(event:ServerSocketConnectEvent):void
                //Thesocket is provided by the event object
                var socket:Socket = event.socket as Socket;
                clientSockets.push( socket );
                socket.addEventListener( ProgressEvent.SOCKET_DATA, socketDataHandler);
                socket.addEventListener( Event.CLOSE, onClientClose );
                socket.addEventListener( IOErrorEvent.IO_ERROR, onIOError );
                //Send a connect message
                socket.writeUTFBytes("Connected");
                socket.flush();
                trace( "Sending connect message" );
            public function socketDataHandler(event:ProgressEvent):void
                var socket:Socket = event.target as Socket
                //Read the message from the socket
                var message:String = socket.readUTFBytes( socket.bytesAvailable );
                trace( "Received: " + message);
                // Echo the received message back to the sender
                message = "Echo -- " + message;
                socket.writeUTFBytes( message );
                socket.flush();
                trace( "Sending: " + message );
            private function onClientClose( event:Event ):void
                trace( "Connection to client closed." );
                //Should also remove from clientSockets array...
            private function onIOError( errorEvent:IOErrorEvent ):void
                trace( "IOError: " + errorEvent.text );
            private function onClose( event:Event ):void
                trace( "Server socket closed by OS." );

    again:  unless you're using a server that all players connect to, you should be using adobe's peer-to-peer networking (rtmfp).
    ie, with multiplayer each player can communicate with a server and the server communicates with each player, or you use peer-to-peer communication.  below is an excerpt from a book i wrote (Flash Game Development: In a Social, Mobile and 3D World).
    Social Gaming - Multiplayer Games
    With multiplayer games, data needs to be communicated among the players.  When a player makes a move (changing the game state) the updated game state needs to be communicated to all the other players. In addition, that communication needs to occur in a timely manner. 
    With turn-based games (like card games) that communication among players can take as long as few seconds without degrading the game experience. With real time games (like shooter games), even a 250 millisecond delay in communicating game state leads to a significantly degraded player experience. Consequently, real time multiplayer games require substantial expertise to successfully develop and deploy.
    There are two fundamentally different ways that communication among players can be accomplished. Players can communicate via a server (server-based games) or they can communicate directly from player to player (peer-to-peer) games.
    Server Based Multiplayer Games
    Generally, the code in each player’s Flash game handles the player’s input, transmits player data to the server, receives other players' data and displays the game state. The server receives player data, validates the data, updates and maintains game state and transmits each player’s data to the other players.
    The code used on the server cannot be ActionScript so you will need to learn a server-side coding language like php or c#.  Server-side coding is beyond the scope of this book so I will not cover server-based multiplayer games except to say you need to have advanced coding skills in, at least, two languages (ActionScript and a server-side language) to create these game types.
    Peer-to-peer games
    Since Flash Player 10, you can create multiplayer games without the need of an intermediary server to facilitate player communication.  The Flash Player can use a protocol (Adobe's Real-Time Media Flow Protocol) that allows direct peer-to-peer communication.
    Instead of using server-side code to handle the game logic and coordinate game state among players, each peer in the network handles their own game logic and game state and communicates that directly to their peers and each peer updates their game state based on the data received from others.
    To use peer-to-peer networking each peer must connect with an Adobe server.  Peer-to-peer communication does not go through that server (or it that would not be peer-to-peer) but peers must stay connected with the Adobe server in order to communicate with each other.
    To communicate with the Adobe server you should use your own server URL and developer key. That URL and key can be obtained at http://www.adobe.com/cfusion/entitlement/index.cfm?e=cirrus.
    Below is a simple tic-tac-toe game that uses Adobe's peer-to-peer networking to pair-up players.  The NetConnection class is used to establish a connection to the Adobe server while the NetGroup class is used for peer-to-peer communication.
    I used only a small part of the NetGroup methods for the tic-tac-toe game but there are more available if you are sharing data among many users and/or sharing large amounts of data.
    The tic-tac-toe game is in support files/Chapter 11/multiplayer and is extensively commented

  • Car Customization (Flash Game) Problem

    I'm currently making a car customization flash game, i've already done the coloring part (while user click "Red", the car become "Red").
    The problem is i want to add an animation before changing the color, eg: when user click "Red", a sprayer is going left to right, and the car become "Red" after that. So i make a movie clip named "Spray", and i got 5 labels "Red", "Green", "Yellow", "Orange", "Blue" in following order, i add the movie clip in every label, but it look weird because when user click "Red", it play the movie clip and become "Red", after that user click "Orange", the car will become "Black" (Black is default color of the car) when playing the movie clip. And user click "Green", it become "Black" again before changing to "Green". It always become default color when user choose other colors.
    What i want is remain the car's color when user choose the other color, eg: when user choose "Red", it play the movie clip first, and become "Red", after that user choose "Orange", it play the movie clip and remain "Orange" color in the same time, after that it change to "Orange", and so on so forth.
    Any solution for this? Thanks

    Ok,i will describe the scene that i haven't make the "Spray" movie clip yet, so i won't confuse you. In the main scene, I got 1 movie clip, inside got few labels, as i mentioned before, "Red", "Green", "Yellow", "Orange", and "Blue" labels. Frame 1 contain a image, which is the black color's car image, the other labels contain different color of car image. So the sequence is Frame 1 is the black car, Frame 2 is the "Red" label, Frame 3 is the "Green" label, and continue until Frame 6.
    I got another movie clip which is in the main scene, inside this movie clip is a menu and button, which contain different type of buttons that allow user change the color. It only have 1 Frame, and here is the AS:
    var myCarArray = [Red, Green, Yellow, Orange, Blue];
    for each (var Car in myCarArray) {
        Car.addEventListener(MouseEvent.CLICK, onCarClick);
      Car.buttonMode = true;
    function onCarClick (event:MouseEvent):void {
        MovieClip(parent).car_color.gotoAndStop(event.target.name);
    So what should i do in order to archive the target that i want? I need to show some animation before changing the car's color.

  • MAC / PC flash game issues through standalone flash player

    I had some flash games built for new site. They were built on a PC, and play perfectly through the latest version of flash player, but jump and loop continuously through flash player on mac. Cannot figure out the reason why this is happening. Anyone come across this before?

    we have loaded shockwave Flash NP-PPC plugIn version 7.0R69
    into the plug ins folder of Internet Explorer 5
    We are still having the same problem which is that we cannot
    view a web page which contains a flash movie with some video
    embedded.
    We see the rest of the animation and hear the sound on the
    movie, but can't see the movie.
    When I published the Flash movie I set it to play with Flash
    Player 6 and up.
    The flash movie (on the web page) plays fine on our other OSX
    Macs and PC's.
    thanks
    Pete

  • 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?

  • Small Flash game, really need help please?

    I'm making a small Flash game, which is rotating rings in an image to create a coherent picture. Think of the puzzles in Assassins Creed.
    I have three scenes set up, one with the puzzle, one with a fade to white transition, and one with a congratulatory screen.
    I have this code to check if the orientation of the rings match, but I'm really new to actionscript so I'm not sure if it's right or not.
    function orientationCheck()
    if (center.orientation == 0 && ring1.orientation == 0 && ring2.orientation == 0 && ring3.orientation == 0 && ring4.orientation == 0)
    gotoAndPlay(1,"Scene2");
    else
    stop();
    Unfortunately it keeps playing through the movie and not giving the player time to solve the puzzle.
    I have CS5.5 if that makes any difference, please help, heck I can send you the file so you can see exactly what's going on, just let me know.

    the trace() function is, by far, the most important tool in flash for code debugging.  nothing else even comes close:
    function orientationCheck()
    trace(center.orientation,ring1.orientation,ring2.orientation,ring3.orientation,ring3.orien tation);
    if (center.orientation == 0 && ring1.orientation == 0 && ring2.orientation == 0 && ring3.orientation == 0 && ring4.orientation == 0)
    gotoAndPlay(1,"Scene2");
    else
    stop();
    Unfortunately it keeps playing through the movie and not giving the player time to solve the puzzle.
    I have CS5.5 if that makes any difference, please help, heck I can send you the file so you can see exactly what's going on, just let me know.

  • Flash games on touchpad help

    hi there.
    I have touchpad and try to play games of flash, and have difficulty using.
    I got bejeweled 1 working, having done a google search and found a popcap site link ending with .FLV, It worked great.
    however, when searching for bejeweled 2, on popcap site, came to regular page, where select to play, the page moves everywhere, and I cannot drag jeweled as whole page moves, 
    on my pre 2, I would play by turning pre 2 horizontal, and the small flash game would maximize, and would not shift, the verticle would return to normal, but that does not appear to happen.
    any help would be great.
    how can I play flash games on touchpad so 
    a the game maximises and fills screen.
    b the screen does not move when trying to play the game.
    thanks. Ralph :-) 
    Post relates to: Pre 2 p102ueu (Unlocked EU)

    it appears I can't get bejeweled 1 working correct, again .
    I don't know what I did correct, last time, to get the flash bejeweled working last time. Any help is appreciated.
    how do I get the flash games working correct without game sliding everywhere.
    did do right but now can't figure out.
    is there some specific instruction for using flash games on touchpad.
    thanks in advance. :-)

Maybe you are looking for