View Full Version : Need help with ActionScript !

12-10-2009, 06:17 AM
Hi, I'm trying to make a game with Flash 8 where a character moves with the arrow keys, like in GTA 2:
Left and right keys rotate the character, and up and down keys moves the character forward and back...

I would appreciate some help with the code, since I am a noob with AS.

Thanks ;|

12-10-2009, 02:37 PM
Please Help!!!!!!!!

12-10-2009, 04:12 PM
With what? I'm not going to give out scripts I made but I'll correct yours if you have any. If you don't, google "basic AS2 movement" since that's what you will be using with flash 8 and what you want to do.

The Dude
12-10-2009, 07:03 PM
onClipEvent (enterFrame) {
if (Key.isDown(Key.UP)) {
_y -= 10;

if (Key.isDown(Key.DOWN)) {
_y += 10;

if (Key.isDown(Key.LEFT)) {
_x -= 10;

if (Key.isDown(Key.RIGHT)) {
_x += 10;

I wrote it up for you, just for you. Feel special, and very special at the fact you can't google something.

12-11-2009, 09:59 AM
Thank you very much RazrBlade. Next time I will google it, but I forgot cos I was high...
I will post the game when finished.

Maybe I will google it... The ActionScript you wrote doesn't make the character rotate.

12-11-2009, 11:45 AM
I'll give you a hint, AS uses rotation like the trigonometry layout, ie, right is 0, up is 90, left is 180 and down is 270. Using these values you should be able to guess what you need to do. And Razr's code will work for movement but i recommend you change the value 10 for a variable (for example, add a variable speed = 10 to the frame AS and relace the 10s with the word speed) makes it a whole lot easier to change things if you needed to by allowing you to just change the 'speed = number' part to change the speed in all directions.

12-11-2009, 04:30 PM
Thanks Scorpio, I'll try to make the code.

The Dude
12-11-2009, 05:20 PM
You wanted it to rotate?
I'm gonna cut you.