Flash game creation tutorial - part 1

March 14th update: part 5.3 released.
March 3rd update: part 5.2 released.
February 9th update: part 5.1 released.
December 31st update: 5th part released.
December 23rd update: 4th part released.
December 6th update: 3rd part released.
November 18th update: 2nd part released.

This is a quite long tutorial, so I decided to split it in pieces.
It started as a didactic example about flash game creation.

First of all, I got inspiration from Ball Revamped series (do not remember the link, search it on Google), but I'll add a lot more features. That means more than... two.

Let's start creating the main character.

The hero

Ok, I said I am going to create the Ball, our hero.

So at the moment our hero will be a red circle with a yellow circle inside. It looks good! Maybe you should print it and keep it on your bedroom wall.

First of all, let's think about our interaction with the hero. Basically, I want the hero to move when I press a key.

He will move to the left if I press left key, to the right if right key is pressed, and so on.

So the first hero actionscript will be:

ACTIONSCRIPT:
  1. onClipEvent (enterFrame) {
  2.     if (Key.isDown(Key.LEFT)) {
  3.         _x--;
  4.     }
  5.     if (Key.isDown(Key.RIGHT)) {
  6.         _x++;
  7.     }
  8.     if (Key.isDown(Key.UP)) {
  9.         _y--;
  10.     }
  11.     if (Key.isDown(Key.DOWN)) {
  12.         _y++;
  13.     }
  14. }

It's easy, isn't it?

The enterFrame event simply checks if a key is pressed, and increases or decreases the hero x or y position according to the key pressed.

Click on the movie and press arrow keys to control the hero, click on "reset" to.. hm.. reset the movie

The Power

Well, you will notice that our hero always moves at a fixed speed.

I want to set up a variable to store the speed, so if I want the hero to move faster/slower I only have to change one value.
This is very important since I am planning to develop different levels where hero speed may vary.

I need to set up a "power" variable to move the hero fastly or slowly.

ACTIONSCRIPT:
  1. onClipEvent (load) {
  2.     power = 3;
  3. }
  4. onClipEvent (enterFrame) {
  5.     if (Key.isDown(Key.LEFT)) {
  6.         _x -= power;
  7.     }
  8.     if (Key.isDown(Key.RIGHT)) {
  9.         _x += power;
  10.     }
  11.     if (Key.isDown(Key.UP)) {
  12.         _y -= power;
  13.     }
  14.     if (Key.isDown(Key.DOWN)) {
  15.         _y += power;
  16.     }
  17. }

Now you can change your hero's speed just adjusting the power variable.
The higher the power value, the fastest the hero movement.

The Speed

That's quite better than before, but our hero always moves at the same speed, and always starts without moving.

Now I need some kind of acceleration, and eventually some initial speed.

ACTIONSCRIPT:
  1. onClipEvent (load) {
  2.     power = 0.2;
  3.     yspeed = 0;
  4.     xspeed = 0;
  5. }
  6. onClipEvent (enterFrame) {
  7.     if (Key.isDown(Key.LEFT)) {
  8.         xspeed -= power;
  9.     }
  10.     if (Key.isDown(Key.RIGHT)) {
  11.         xspeed += power;
  12.     }
  13.     if (Key.isDown(Key.UP)) {
  14.         yspeed -= power;
  15.     }
  16.     if (Key.isDown(Key.DOWN)) {
  17.         yspeed += power;
  18.     }
  19.     _y += yspeed;
  20.     _x += xspeed;
  21. }

Notice how I reduced the power from the previous example (3) and this one (0.2).
Now that the power increases the speed, I need to play carefully with it or our hero will move too fast.
I have a yspeed and xspeed values starting at 0, but I can change them to make the hero move as he enters the frame.

Now, the more you press a key, the more your hero gains speed, the harder is to change direction.

Good.

The Fritcion

But now I want a friction, because I do not want the hero to move forever if I don't press any key.
I want the hero to slowly stop moving if no key is pressed.

ACTIONSCRIPT:
  1. onClipEvent (load) {
  2.     power = 0.3;
  3.     yspeed = 0;
  4.     xspeed = 0;
  5.     friction = 0.95;
  6. }
  7. onClipEvent (enterFrame) {
  8.     if (Key.isDown(Key.LEFT)) {
  9.         xspeed -= power;
  10.     }
  11.     if (Key.isDown(Key.RIGHT)) {
  12.         xspeed += power;
  13.     }
  14.     if (Key.isDown(Key.UP)) {
  15.         yspeed -= power;
  16.     }
  17.     if (Key.isDown(Key.DOWN)) {
  18.         yspeed += power;
  19.     }
  20.     xspeed *= friction;
  21.     yspeed *= friction;
  22.     _y += yspeed;
  23.     _x += xspeed;
  24. }

So I introduced a friction, minor than 1, that will affect hero's speed. Now, when I press a key the hero starts moving, but when I release the key the hero will slowly stop. How slowly? The higher the friction (always minor than 1, remember), the slowly our hero will decrease his speed.

The Gravity

I said I wanted to do something similar to Ball Revamped, so I need a gravity. The hero will fall according to gravity strenght.

ACTIONSCRIPT:
  1. onClipEvent (load) {
  2.     power = 0.3;
  3.     yspeed = 0;
  4.     xspeed = 0;
  5.     friction = 0.95;
  6.     gravity = 0.1
  7. }
  8.  
  9. onClipEvent (enterFrame) {
  10.     if (Key.isDown(Key.LEFT)) {
  11.         xspeed -= power;
  12.     }
  13.     if (Key.isDown(Key.RIGHT)) {
  14.         xspeed += power;
  15.     }
  16.     if (Key.isDown(Key.UP)) {
  17.         yspeed -= power;
  18.     }
  19.     if (Key.isDown(Key.DOWN)) {
  20.         yspeed += power;
  21.     }
  22.     xspeed *= friction;
  23.     yspeed += gravity;
  24.     _y += yspeed;
  25.     _x += xspeed;
  26. }

So I replaced the friction with the gravity for vertical movements. If I do not press UP arrow, the hero will fall down. When you read this line, probably the hero has fallen outside of the movie (you'll see how to prevent this later in the tutorial), so you may need to click on reset to place the hero at the center of the movie.

The Thrust

If I have gravity, I need a thrust. I want to be more complicated to move up since my hero is living in a world where gravity exists.

ACTIONSCRIPT:
  1. onClipEvent (load) {
  2.     power = 0.3;
  3.     yspeed = 0;
  4.     xspeed = 0;
  5.     friction = 0.95;
  6.     gravity = 0.1;
  7.     thrust = 0.75;
  8. }
  9.  
  10. onClipEvent (enterFrame) {
  11.     if (Key.isDown(Key.LEFT)) {
  12.         xspeed -= power;
  13.     }
  14.     if (Key.isDown(Key.RIGHT)) {
  15.         xspeed += power;
  16.     }
  17.     if (Key.isDown(Key.UP)) {
  18.         yspeed -= power*thrust;
  19.     }
  20.     if (Key.isDown(Key.DOWN)) {
  21.         yspeed += power*thrust;
  22.     }
  23.     xspeed *= friction;
  24.     yspeed += gravity;
  25.     _y += yspeed;
  26.     _x += xspeed;
  27. }

As you can see, thrust (again minor than 1) affects the UP movement, making it weaker and more complicated to accomplish

The Wind

What's now? Sure, the wind!
I want to make the stage look windy, you know, heros' life is complicate, so that's it!

ACTIONSCRIPT:
  1. onClipEvent (load) {
  2.     power = 0.3;
  3.     yspeed = 0;
  4.     xspeed = 0;
  5.     friction = 0.95;
  6.     gravity = 0.1;
  7.     thrust = 0.75;
  8.     wind = 0.09;
  9. }
  10. onClipEvent (enterFrame) {
  11.     if (Key.isDown(Key.LEFT)) {
  12.         xspeed -= power;
  13.     }
  14.     if (Key.isDown(Key.RIGHT)) {
  15.         xspeed += power;
  16.     }
  17.     if (Key.isDown(Key.UP)) {
  18.         yspeed -= power*thrust;
  19.     }
  20.     if (Key.isDown(Key.DOWN)) {
  21.         yspeed += power*thrust;
  22.     }
  23.     xspeed += wind;
  24.     xspeed *= friction;
  25.     yspeed += gravity;
  26.     _y += yspeed;
  27.     _x += xspeed;
  28. }

Wind affects side movements, if positive will move the hero to the right, if negative will move the hero to the left.
Play with all those variables wisely and find a perfect mix of realism and playability.

The Rotation

Now, the final touch. Just like in Ball Revamped, I want the hero to rotate clockwise when moving to right, and counter clockwise when moving to left.

ACTIONSCRIPT:
  1. onClipEvent (load) {
  2.     power = 0.65;
  3.     yspeed = 0;
  4.     xspeed = 0;
  5.     friction = 0.99;
  6.     gravity = 0.1;
  7.     thrust = 0.75;
  8.     wind = 0.05;
  9. }
  10. onClipEvent (enterFrame) {
  11.     if (Key.isDown(Key.LEFT)) {
  12.         xspeed -= power;
  13.     }
  14.     if (Key.isDown(Key.RIGHT)) {
  15.         xspeed += power;
  16.     }
  17.     if (Key.isDown(Key.UP)) {
  18.         yspeed -= power*thrust;
  19.     }
  20.     if (Key.isDown(Key.DOWN)) {
  21.         yspeed += power*thrust;
  22.     }
  23.     xspeed += wind;
  24.     xspeed *= friction;
  25.     yspeed += gravity;
  26.     _y += yspeed;
  27.     _x += xspeed;
  28.     _rotation += xspeed;
  29. }

That's easy, I only need to se the hero rotation equal to his xspeed.

This is where the first part ends... leave me feedback and tell me what do you think about it.

Here it is a zipped file with all source codes explained in this tutorial.

Continue with the 2nd part...

If you liked this post buy me a beer (or two)

» Flash Templates provided by Template Monster are pre-made web design products developed using Flash technology.
They can be easily customized to meet the unique requirements of your project.

164 Comment(s)

  1. qhiiyr | Oct 30, 2006 | Reply

    Great tutorial! I’ve been wanting to learn actionscript, and this is a great introduction to it. One thing though: I think the last flash demo window (when the ball is supposed to rotate) is the same as the first one. Whoops!

  2. santosh maharana | Nov 3, 2006 | Reply

    this is a very nice tutorial. becoz this script lets you to control the caracter just like a game.
    thanx to those brillient mind who had given this idea.

    i request you, that Will you please send me some tutorials for aading nice effects to the text alongwith animation only via script not by frame.

    Regards

    santosh maharana
    (web developer)

  3. André Pinto de Oliveira | Nov 3, 2006 | Reply

    Hey.. is a cool and easy tutorial… =]

    tks.

    Regards…

  4. Mat | Nov 10, 2006 | Reply

    Pretty neat tutorial, I was looking into flash for some small game creations instead of XNA while I wait to get out of high school and into college. I think i’ll try this one and some others i found.

    Thx,
    Mat

  5. V34 | Nov 12, 2006 | Reply

    Hello, thanks for making this tutorial. But as the first said. The last and the first The both are /downloads/just_move.swf (:

    But i learned alot from these tutorials, and you keep it simple. Thats nice. Thanks alot!

  6. Emanuele Feronato | Nov 12, 2006 | Reply

    Fixed

  7. morgan | Nov 13, 2006 | Reply

    hey the tutorial really helped me out alot seeing how i started flash just recently

    i have a question though

    how would you stop the ball from moving on contact with a wall or platform or boundary

    i tried to figure it out my self many times and here were my problems

    1.when i hittest the wall i made the xspeed = 0, but the meant that couldent move left off the wall either

    2.i fixed that by saying if (hit test the wall) xspeed = -0.1 which nugged the ball off the wall and let me regain left control again, but the friction property carried the ball threw the wall

    3.then i made it so friction is off and xspeed=0.1 and that works almost perfectly, and i say almost because now what happends is the ball goes a little bit into the wall and then is pushed back out, which works and you barley notice but looks really sloppy

    so could you show me how to use those same physics including gravity but stop on contact with walls and esspecially the ground, im trying to make a little jet pack kinda game

  8. Emanuele Feronato | Nov 13, 2006 | Reply

    Hi morgan,
    I will explain during next days all kind of collision of our hero

  9. morgan | Nov 13, 2006 | Reply

    thanks alot thats good

    because ive been yelling at my computer screen for 2 days now

    great tutorial by the way, the code is simpler than anyone elses ive seen and by far works the best

    and i hope your tutorial covers oddly shaped terrain because if i have to figure it out myslef ill probly rip the screen or my laptop before i figure it out

  10. morgan | Nov 15, 2006 | Reply

    hello

    i tried somthing and i was hoping you could tell me what i did wrong

    i had the wall return a hittestboolean GRAVITYALLOWED=false

    and the code at the bottom of all you have up there inside the ball went like this

    if(gravity allowed=true)
    xspeed*=friction
    yspeed =gravity

    if(gravity allowed =false)
    xspeed*=friction
    yspeed=0

    why does it sink threw a little before stopping!?

    if i drop the ball from high enough at the begining it goes almost all the way threw my little box for the ground
    by the way im really looking forward to more of ur tutorials

  11. Emanuele Feronato | Nov 15, 2006 | Reply

    It depends on how do you check the collision.
    Second part is coming in a few hours…

  12. Conor | Nov 19, 2006 | Reply

    Why are there errors even though I am copying the actionscript from the tutorial?

    When you draw the ball, how do u make sure that it is the ball that you’re moving?

  13. Emanuele Feronato | Nov 19, 2006 | Reply

    You should paste the code in the hero istance in the main scene.
    See the source code I provided.

  14. Sphankey | Nov 24, 2006 | Reply

    Quite cool I must say. But I’m not sure if I need it.

    You’re good man.

  15. Polska Liga Soldat | Nov 26, 2006 | Reply

    Nice tutorial about basic of physics in 2d world :-)

  16. dhaval | Nov 29, 2006 | Reply

    hi,

    this is really cool tutorial

    but i have littel question

    after i finish this game. it was working fine.

    i solved the problame about the coin out side of wall

    but now my hero is not hitting the coin.

    i try to arrange it with right cliick.

    but some time it goes from the top of the coin, some time beneth the coin.

    it is not hitting the coin.
    can any budy help me please.

    thanks

    dhaval

  17. Yoki | Nov 30, 2006 | Reply

    such a great tutorial for me… Thanks to the one who made this tutorials… i’ve learned a lot of this…

  18. Sean | Dec 4, 2006 | Reply

    My ball keeps on moving really really fast and i don’t know how to slow it down.

    The tutorial is great

  19. RDFNWY | Dec 6, 2006 | Reply

    Where do i start from scratch, like what do i do with those script code? Is there a program?

  20. Joshua | Dec 14, 2006 | Reply

    Best tutorial ever. Showing a sample after each step makes everything so much better!

  21. guesswho | Dec 14, 2006 | Reply

    it’s a great strip, but when I did the first step it went just fine.On the second step it din’t change the speed. maybe it’s because I kept ONE action script instead of many, i dont know how to make numerous scripts for one symbol.

    plz help
    thanks in advance,
    guesswho

  22. guesswho | Dec 14, 2006 | Reply

    sorry when I said strip I meant tutorial
    ahhh whoooooops
    ‘.’

  23. CoolGuy | Dec 14, 2006 | Reply

    so u make the hero then u create an actionscript?

  24. guesswho | Dec 16, 2006 | Reply

    reply to CoolGuy:

    yes. Draw and make the character, then make it a symbol. I find it works better when you make it a movieclip. Click on the hero you made. Open the actionscript and start writing the code.

  25. Sneha | Dec 16, 2006 | Reply

    Great tutorial!!

  26. alex | Dec 17, 2006 | Reply

    this has to be the most easiest, fun and more of an understanding that the other tutorials i have read. this has to be the best one ever made

  27. Amen | Dec 18, 2006 | Reply

    nice tutorial, i like it

    thank you.

  28. Ravikumar | Dec 19, 2006 | Reply

    hi
    I am present learning scripting.
    this is the nice tutorial for me.
    i learn more from this tutorial.

  29. Fire Caller | Dec 20, 2006 | Reply

    This is a 100% great tutorial. I have been looking hard for a game tutorial with immediate results and this is it. Just one problem, when I finish my game, the ball speed is jerky and slow.

  30. Salman | Dec 24, 2006 | Reply

    Hey it’s a really kewl tutorial. But it only has one problem. You didn’t explain everything very well. Sorry to say that but it’s true. Maybe if you explain everything a little bit more, then more people will come and try to learn from your website. ☺

    ♫♪♫♪♪♫♪♫

  31. Salman | Dec 24, 2006 | Reply

    how did you even create the ball????

  32. Zach Hill | Dec 31, 2006 | Reply

    I am *trying* to make an extensive flash game or even a full game with my friend. This tutorial you have compiled looks promising, so I will try it. Thank you!

    By the way, I found the Ball Revamped series:
    [http://www.ebaumsworld.com/ballrevamped.html]

  33. Francois | Jan 4, 2007 | Reply

    Wow great tutorial, one can never learn to much action script. Out of all the game tuts I’ve read up on, this is my favorite.

    Thanks!

  34. yura | Jan 4, 2007 | Reply

    Hey. Got to tyhe first part but is says i have an error the error is the following=Scene=Scene 1, Layer=hero, Frame=1: Line 1: Clip events are permitted only for movie clip instances.
    see that is the error and my hero wont move so plz email me and tell me what i did wrong???

  35. yura | Jan 4, 2007 | Reply

    hey never mind i found what i did wrong. i didnt put the hero on moviescript

  36. Justin | Jan 5, 2007 | Reply

    What was the action script used for the reset button?

  37. Vitor | Jan 7, 2007 | Reply

    Nice tutorial indeed. Simple, easy to understand, simple code and goes direct to the point. Nice work.

  38. ben | Jan 8, 2007 | Reply

    hi i am in need of a tutorial to help me make a game which involves asking and answering questions

  39. Hugh | Jan 9, 2007 | Reply

    hey, I just started this tutorial with a high interest in flash, and game design. I thought I should try out this tutorial, and everything was going well up until you asked to put in a variable for the “hero’s” speed. I keep being told that the variable was incorrect and cannot be used until its fixed. I believe that this is caused by my lack of experience in flash. please get back to me, prefferably by email, which I left.

    Thanks,

    Hugh

  40. DocBleach | Jan 11, 2007 | Reply

    Hi, thanks!
    This tutorial has been really helpfull thanks!

  41. attacklvl98 | Jan 19, 2007 | Reply

    great man!! i just started flash a.s. and this really helped 1 question though. how do u make the ball rotate the same way of the arrow that you are pushing?

  42. attacklvl98 | Jan 21, 2007 | Reply

    ok lol maybe my thing didnt make sence…the reason why i am asking is because my ball just keeps a constant rotation no matter what i do..how would i make it rotate in the direction that i push? (is that more clear) lol

  43. flash the hedgehog | Feb 1, 2007 | Reply

    Great tutorial, im getting flash 8 soon, probably. Anyway, this tutorial will probably help me a lot when i get it. Im thinking of making a sonic the hedgehog flash game for my website. MAybe even a sonic battle flash game.

  44. helper monkey | Feb 2, 2007 | Reply

    great tutorial!! but one thing i like to add to my games like that is:
    if (_y 400) {
    _y = 0;
    }
    if (_x 550) {
    _x = 0;
    }
    this will make it so that when the hero goes off one side of the screen, he comes back on the other!! =)

  45. helper monkey | Feb 2, 2007 | Reply

    sry bout that stupid moderation took half the script out :(
    -attacklvl98,
    all you have to do is put in
    if (Key.isDown(Key.LEFT)) {
    _rotation -= 15;
    }
    then the sme for right, except adding the rotation.
    hope this helps! =)

  46. Zee7 | Feb 3, 2007 | Reply

    sir i learn your gamming tutorial in flash its realy intresting but here is a little problem and its that you did not put high detail with you tutorial.

    Anyways its realy good i will get many things from your tutorials.

    Sir i hope you know flash coding very well i just want to ask one thing to you that are you only work in gamming i mean do you make flash base wensite……..

    if you will write tutorials on full flash base scripting.then i will be thanksfull to you.

    sir i am webdesigner and currently designing websites in flash but i dont know flash coding very well..

    I hope that you can help me sir i will wait for your new tutorials ..

    Sir i will be thankful to you if you send me tutorials that i require ….

    thanks for readin this message………….please reply me back either you want to help me or not …….please

    With best regards.
    Zee7………….^^

    my email address is zee7_idol@yahoo.com

  47. Zee7 | Feb 3, 2007 | Reply

    sir i realy want to know about flash scripting and i cant learn this from our country i mean l live in pakistan and i have limited resources at here i mean i cant learn about flash scripting at here…………but i visit you site and i dont know why am i writing these things..

    But my heart i saying that i will get something from you.sir now i am depend on you i mean i will wait for help from you.

    sir i just want to know full flash website coding level.I told you befor that i am currently making full flash sites.

    Please contat me i realy need you help and hope that you will be prove yourself a great leader for me..

    Thanks for reading these messages……….thanks ..thanks

    must reply back ……

  48. attacklvl98 | Feb 6, 2007 | Reply

    thanks helper monkey that fixed the problem.

    c u guys later

  49. Ian | Feb 7, 2007 | Reply

    very simple and easy to understand tutorial, great introduction to flash game programming due to the lack of complicated maths

  50. Glucozade | Feb 12, 2007 | Reply

    my script doesn’t work..when i try it, it says

    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 1: Clip events are permitted only for movie clip instances
    onClipEvent (enterFrame) {

    what that about?

    plz help.

    (im hoping to get my skills good enough to make a small but fully playable game)

  51. glucozade | Feb 12, 2007 | Reply

    im getting the same problem as yura, but i dont know how to turn the hero in to moviescript(?). can anyone please help me?

    PS can i use a sprite from a game instead of the ball?

  52. Glucozade | Feb 12, 2007 | Reply

    ARGH!!!! im getting frustrated here. my script isnt working:

    **Error** Scene=Scene 1, layer=Sonic, frame=1:Line 1: Clip events are permitted only for movie clip instances
    onClipEvent (enterFrame) {

    Total ActionScript Errors: 1 Reported Errors: 1

    This message always comes up. WHY?!?!!? Somebody plzzzz help me

  53. glucozade | Feb 13, 2007 | Reply

    Never mind i fixed it somehow

  54. Daniel | Feb 25, 2007 | Reply

    Great tutorial m8!

    Really helped I changed the ball for a ship but used the same movement code (-wind) as a starship game it works great.

    thanx alot

    Dan
    Graphic Designer

  55. ronald | Mar 1, 2007 | Reply

    just started with flash and i didnt know anything about it
    thanks to your tutorial i’m starting to get it
    i only think that u should make a part 0.1 to show people where they should put their scripts, because i couldnt find it, anyway thanks for the tutorial .

  56. mario | Mar 2, 2007 | Reply

    It does not work, because there is no instance attached to the script.

    thanks

  57. mario | Mar 6, 2007 | Reply

    tutorial will not work for me. there is no instance attachment.

  58. Ryke | Mar 14, 2007 | Reply

    Just wondering, what does the thrust do anyway

  59. Fittan | Mar 15, 2007 | Reply

    action script suck, it never works. i always get up errors all the time

  60. ksk | Mar 16, 2007 | Reply

    keeps giving me error messages plz help

  61. Kyle Poole | Mar 22, 2007 | Reply

    Ok, here is the stupidest question ever, HOW DO I OPEN ACTIONSCRIPT? I cant figure it out, i have a ball, but i cant even see the actionscript window to type that stuff in, or do you not even type it, im totally a newb at this so far, but right now im trying to use flash durings chool, and its slightly difficult so far, so how do i do that? or do you have a tutorial that i can go look at elsewhere? ty!

  62. LRG | Mar 28, 2007 | Reply

    I was wondering how do you change a script to a game that is my problem.

    Also…Nice

  63. shwagman | Mar 29, 2007 | Reply

    was very informative and easy to learn, thanks a ton! you don’t know how happy this has made me!!

  64. radcobra | Mar 30, 2007 | Reply

    the ball is too fast i tried changing power and thrust but no use and i even change the fps
    would someone tell me what should i do

  65. serkan | Mar 31, 2007 | Reply

    onClipEvent (load) {
    yspeed = 0;
    xspeed = 0;
    wind = 0.00;
    power = 0.65;
    gravity = 0.1;
    upconstant = 0.75;
    friction = 0.99;
    }
    onClipEvent (enterFrame) {
    if (Key.isDown(Key.65))
    xspeed = xspeed-power;
    }
    if (Key.isDown(Key.68)) {
    xspeed = xspeed power;
    }
    if (Key.isDown(Key.87)) {
    yspeed = yspeed-power*upconstant;
    }
    if (Key.isDown(Key.83) {
    yspeed = yspeed power*upconstant;
    }
    xspeed = (xspeed wind)*friction;
    yspeed = yspeed gravity;
    _y = _y yspeed;
    _x = _x xspeed;
    _rotation = _rotation xspeed;

    if (_root.wall.hitTest(_x, _y, true)) {
    xspeed = 0;
    yspeed = 0;
    _x = 120;
    _y = 120;
    _root.bscore -=2;
    }
    if (_root.coin.hitTest(this.hero_hit)) {
    _root.coin._x = Math.random()*400 50;
    _root.bscore =2;
    }
    }

    as you have seen ı have only changed the keys to a s d w with their codes but ı am getting and he is the error “**Error** Scene=Scene 1, layer=hero2, frame=1:Line 11: ‘)’ or ‘,’ expected
    if (Key.isDown(Key.65))

    **Error** Scene=Scene 1, layer=hero2, frame=1:Line 14: ‘)’ or ‘,’ expected
    if (Key.isDown(Key.68)) {

    **Error** Scene=Scene 1, layer=hero2, frame=1:Line 15: Statement must appear within on/onClipEvent handler
    xspeed = xspeed power;

    **Error** Scene=Scene 1, layer=hero2, frame=1:Line 16: Unexpected ‘}’ encountered
    }

    Total ActionScript Errors: 4 Reported Errors: 4

    any idea why???

  66. R3AP3R | Apr 3, 2007 | Reply

    i want to learn to make flash games but i understand the html a bit but where do i put the html to get that ball screen wordpad? or another program?

  67. smritii | Apr 4, 2007 | Reply

    hi
    this is great tutorial for game designing
    i found a path and initial start for flash games

  68. sam | Apr 4, 2007 | Reply

    hey…i was making a car racing game and didn’t need gravity, wind etc.
    so i tried to use the friction code. i put it into my car MC and got this error…

    **Error** Scene=Scene 1, layer=Layer 1, frame=3:Line 1: Statement must appear within on/onClipEvent handler
    1.

    **Error** Scene=Scene 1, layer=Layer 1, frame=3:Line 13: Syntax error.
    7. onClipEvent (enterFrame) {

    Total ActionScript Errors: 2 Reported Errors: 2

    please help me…

    other than that, the tute was good and easy to follow :D

  69. sam | Apr 4, 2007 | Reply

    also…when my other problem is fixed….it came to me that i would need to put something in to make the finish line determine who wins (p1 or p2)
    and bring up a winner screen…i know sort of about hit test but i would like to be able to make it that you have to do say 3 laps before the win screen comes up…and make it so somebody couldn’t cheat by just reversing straight into the finish line…

    i know that probably didn’t even make sense…oh well please get back to me soon…

    Sam. o_0

  70. Omar G. | Apr 7, 2007 | Reply

    hey do you think you could make a fighting game tut that covvers walk and hiting combos and enemy AI. im tring to make a fighter and i need help on Ai and combos , heck i even need help on making the dang character walk (the animation of him walking). i think you tuts are easier to understand and more detailed which is way im asking, so do you think you can help me out?

    or could you email one to me
    my email’s legean1@hotmail.com

  71. sam | Apr 7, 2007 | Reply

    hey Omar….this probably wont help and ur probably way better than me at flash anyway…but oh well
    if by the character walking u mean for example when you press right the feet move then this one might help you….http://www.tutorialized.com/tutorial/Walking-Movie-Clip/2422
    look at the source file…and see how there r frames of the walking animation in the moviclip…and in the script it says when you press a key…it plays…if that makes sense i hope it helps…

    this dude hasn’t seemed to reply for a while…i like awesty…try him on…www.awestyproductions.com

  72. Omar G. | Apr 8, 2007 | Reply

    thanks ill check them out

  73. J-Dizzle | Apr 8, 2007 | Reply

    uummm, how do you open an actionscript thing?

  74. Omar G. | Apr 9, 2007 | Reply

    if we’re thinking the same thing right click and go to actions thats the actionscript area(you could also click the actions panel on the bottum.)

    if thats not what you mean then i cant help you, sorry.

  75. CBURNS | May 3, 2007 | Reply

    Hi There

    I get this error :
    __________________________________________

    **Error** Symbol=Symbol 45, layer=Layer 1, frame=1:Line 18: Syntax error.
    0._visible = “0″;

    Total ActionScript Errors: 1 Reported Errors: 1

    __________________________________________

    When my script looks like this :

    onClipEvent (enterFrame)
    {
    if (_parent.entrada == null)
    {
    if (this._xscale

  76. Andreius | May 6, 2007 | Reply

    ive been making a car racing type game, and ive managed designing the levels, made character, added if (Key.isDown(Key. -x-)
    statmentsd to move down and up and ive added rotation for left and right…
    it all works perfect ( no syntax errors)
    but when using up and down keys it uses the default north and south.. i want to know how to get it going forward and back but the way the car is actually facing…

    any help at all highly appreciated

    thx in advanced

  77. Andreius | May 6, 2007 | Reply

    to burns:

    well for us to help you could try showing us line 18

  78. mickyas | May 10, 2007 | Reply

    how do i play the game i made.

  79. mickyas | May 10, 2007 | Reply

    please some1 answer me…

    great tutorial emanuel…
    its totaly awsome!

  80. tom | May 16, 2007 | Reply

    OMFG OMFG OMFG
    I CANNOT GET THIS TO WORK!!!

    AHHHHHHHHHHHHH FAR OUUUUT!
    I keep getting errors… Every tutorial i do i get
    fuking errors!

    **Error** Scene=Scene 1, layer=Layer 2, frame=1:Line 1: Statement must appear within on/onClipEvent handler
    1.

    **Error** Scene=Scene 1, layer=Layer 2, frame=1:Line 13: Statement must appear within on/onClipEvent handler
    7.

    Total ActionScript Errors: 2 Reported Errors: 2

  81. Elfvision | May 20, 2007 | Reply

    thanks alot!
    really nice tutorial!
    i was always searching for a tutorial which would teach me how to make objects move using arrow keys and how to give thrust and etc.
    thanks ALOT!
    really liked this tutorial

  82. Deimox | May 20, 2007 | Reply

    First off all i want to thank you for your amazing tut!
    now my idea is to create a ball whose position is equal to mouse position…but that part is easy (_root.[my object]._y = _root.mouse_y and _root.[my object]._x = _root.mouse_y)

    now i want to have a canon incorporated in the ball that rotates when i press the left and right arrow keys, this part ir already done too (if(Key.isDown(Key.LEFT)){ this._rotation = 10)

    this part is the trouble…
    I dont know how to make it shoot a bullet in the direction wich the cannon is facing…thats were i need your help…

    thx
    Deimox

  83. flashbynight | May 28, 2007 | Reply

    Good basic tutorial.

    Flash is a great tool for small-time developers.

  84. Ted | Jun 5, 2007 | Reply

    the first script isnt working:

    **Error** Scene=Scene 1, layer=Action, frame=5:Line 1: Clip events are permitted only for movie clip instances
    onClipEvent (enterFrame) {

    Total ActionScript Errors: 1 Reported Errors: 1

  85. Scott | Jun 15, 2007 | Reply

    great tutorial! ive been searching google forever trying to find a complete tutorial. although this just has the hero…. its helped me a lot, since i just started flash.

    thanks.

  86. Samus Man | Jun 19, 2007 | Reply

    I have to say–this tutorial is looking optimistic. I’m actually entering a competition in less than 30 days, so I need something like this–complete enough to teach me most of what i’ll need and detailed enough so that I can adapt the concepts to my own engine.

  87. flaming | Jun 24, 2007 | Reply

    I keep getting this error.

    **Error** Symbol=hero, layer=Layer 1, frame=1:Line 1: Clip events are permitted only for movie clip instances
    onClipEvent (enterFrame) {

    Total ActionScript Errors: 1 Reported Errors: 1

    I’ve seen other ppl fix it but didn’t explain how.

    Plz help me.

  88. flaming | Jun 24, 2007 | Reply

    Nvm fixed it by clicking the “hero” tab at the bottom.

  89. flaming | Jun 24, 2007 | Reply

    whenever i test it, it rus slowly and shakes. How do i run it without the shaking?

  90. eggel | Jun 28, 2007 | Reply

    how do u make the hero a moviescript

  91. Jimmy P | Jun 28, 2007 | Reply

    Hey, I want to start with saying that this is a great tutorial! I just got Adobe Flash CS3 Proffesional a few days ago. And I want to start making a really simple game, so I was wondering how you put this actionscript, and the character that you’ve created, together to make it move?

  92. Izz | Jul 6, 2007 | Reply

    help please!
    I’m pretty new to flash, and ive got a problem with my flash 8. It used to work fine but and when I drew and object and clicked on it, it would be appear normally with a blew rectangle around it. Now when ever I draw something and select it, it automatically has these dots all over it… kind of like it’s already broken apart (I think that’s the term anyway…).
    Anyway, it’s being a bit restricting. Does anyone know how to fix this

  93. Tim F | Jul 14, 2007 | Reply

    Great Tutorial

    The last one (rotation).
    It’s very great!!!
    And usefull to make rolling balls like RocoLoco (PSP).

    TF

  94. Dan | Jul 20, 2007 | Reply

    This is a really nice tutorial. But I have a problem. I copy and pasted your script, but my hero still wouldn’t move.

  95. BoJaN | Jul 20, 2007 | Reply

    wow! thank you so much, i’ve been looking for a great tutorial for a long time but all the ones i find start past the basics I usually do coding in
    LSL, a scripting language in an MMO and im out of things to program for it so I wanted to learn somthing different and i’m so happy with this tutorial!! Thanks a bunch!

  96. shirin | Jul 25, 2007 | Reply

    hi, i cant open source codes with flash mx 2004. what to do?

  97. SHINOBI | Aug 5, 2007 | Reply

    I love this tutorial! Thanks so much!

  98. Dreamspeaker | Aug 8, 2007 | Reply

    Where do you get the stuff to make flash games?

  99. nate | Sep 16, 2007 | Reply

    where do i get actionsrcipt at

  100. Joan | Sep 18, 2007 | Reply

    hey… thanks for this tutorial! really helps…

  101. Lazar | Oct 5, 2007 | Reply

    Really good tutorial, but I don’t know only one little thing: HOW, TO HELL, WILL I PLAY THIS GAME ON MY COMPUTER? I copied the plain text in *.txt file, but how will I play it?

  102. Lazar | Oct 6, 2007 | Reply

    How, to hell, can I play this game?

  103. s0d4player | Oct 19, 2007 | Reply

    Note to many. If you get this:
    **Error** Symbol=hero, layer=Layer 1, frame=1:Line 1: Clip events are permitted only for movie clip instances
    onClipEvent (enterFrame) {
    your probably putting the actionscript on the frame, not on the movie clip.
    Make sure that you are editing the actionscript on the movie clip.

  104. Thibledorf | Oct 27, 2007 | Reply

    Hi this is a noobish question but how do I make an action script that dose the same thing as a go to and play command?

    I want to make it so that the hero goes to a different scene when you press one of the directional buttons.

  105. Thibledorf | Oct 28, 2007 | Reply

    Hi, I figured out the answer to my first question but now I need to know how to make it so the directional keys only function when the oposite key is up.

    Here is an example of what I mean, using codes that for some reason don’t seem to work:

    if (Key.isDown(Key.UP) && Key.isUp (Key.DOWN)) {
    yspeed -= power;
    gotoAndstop(81);

  106. Menno | Oct 29, 2007 | Reply

    Hey guys, just to respond on the refresh button… I searched it for some time too, and found a great solution. This is simulair to the refresh browser button, but now it will only refresh the flash clip.

    on(release){
    loadMovieNum(_root._url.substring(_root._url.lastIndexOf(”/”)+1),0);
    }

  107. picklejoe | Nov 4, 2007 | Reply

    its cool but never works
    does it work on KoolMoves?

  108. picklejoe | Nov 4, 2007 | Reply

    what the crap???? it never works! not as a sybmol or/and a movie clip!!!!!!!!!

  109. Trevor | Nov 6, 2007 | Reply

    You guys are awsome i want to make a flash game but i dont know how to so ill just keep playing for right now. You guys are awsome!!!!

  110. mister dunno | Nov 9, 2007 | Reply

    i got only 1 question what program do in need to make a game like this

  111. stevie | Nov 11, 2007 | Reply

    how do u make a reset button?

  112. stevie |