Switching animations at key press/Controlling Character

I’m pretty new to flash 5. My only accomplishment so far with it was to create a space shooter game which i modified slightly and animated it or at least the enemy spache ships and the players spaceship.\r\rHere is what I want to do, but cant seem to figure out\r\rI want to have a character on screen who is standing stationary normally, but still facing a direction.(left or right)\r\rNow I want to be able to switch to a walking animation towards the right when I press a key and a seperate animation for when he walks left also at the press of a key\rI want to do down and up to, but I should be able to figure those out once I learn left and right\r\rI also want it so when I lt go of the key they stop the walking animation and return to stationary, but stay facing whatever direction i pointed them

bump… interesting problem.\r\r_yscale=-100; will set an object to flip horizontaly… that’s going to be part of the answer.\r_y++; will move an object 1 pixel to the right, the opposite, _y–; will move an object 1 pixel to the left… this is another part of the answer.\r\rI’ll think about this… it might be a little complex, but if you’ve created a shooter then you’re well on your way. Give me a day or two.

Here is the script I’m using currently for the character \rI doesnt lock up when I run this, but it seems like the animation is locked on the first frame and not going to any of the frames I specify \r\r\r\r\ronClipEvent(load){ \r\rmoveSpeed=5; \r\r} \r\r\r\r\ronClipEvent (enterFrame) { \r\r\rif (Key.isDown(Key.RIGHT)) { \rthis._x+=moveSpeed; \rgotoAndPlay( 3 ); \r} else if (Key.isDown(Key.LEFT)) { \rthis._x-=moveSpeed; \rgotoAndPlay( 13 ); \r} \rif (Key.isDown(Key.DOWN)) { \rthis._y+=moveSpeed; \rgotoAndPlay( 8 ); \r} else if (Key.isDown(Key.UP)) { \rthis._y-=moveSpeed; \rgotoAndPlay( 28 ); \r} \r\r} \r\r

Try and debug your movie :

 onClipEvent (enterFrame) {\r\rif (Key.isDown(Key.RIGHT)) {\r\r_root.a = 1 ;\r\rtrace (a) ;\r\rthis._x+=moveSpeed;\r\rgotoAndPlay( 3 );\r\r} else if (Key.isDown(Key.LEFT)) {\r\r_root.a = 2 ;\r\rtrace (a) ;\r\rthis._x-=moveSpeed;\r\rgotoAndPlay( 13 );\r\r}\r\rif (Key.isDown(Key.DOWN)) {\r\r_root.a = 3 ;\r\rtrace (a) ;\r\rthis._y+=moveSpeed;\r\rgotoAndPlay( 8 );\r\r} else if (Key.isDown(Key.UP)) {\r\r_root.a = 4 ;\r\rtrace (a) ;\r\rthis._y-=moveSpeed;\r\rgotoAndPlay( 28 );\r\r}\r\r} 

\r\rpom 0]

ok I tried your suggested script and now it still hasnt changed except now it shows the error box, yet no errors are listed\rand the box keeps getting more full every time I push anything

I know, that was not supposed to change your script, but merely to check which loop you enter, and if you actually enter the loop. If what you call the error box, which is in fact the output of my trace function, doesn’t show anything, it’s totally normal, cos there’s a mistake in my script. You should

 trace (_root.a) ;

and not just a.\r\rAnyway, what’s happening on frame 3… ?\rYou can also post the fla so that someone here checks it out.\r\rpom 0]

Hey, I used your script word by word (I only changed the gotoAndPlay into gotoAndStop) and here’s what I get (click the movie first) :\r\rpom 0]

I progressed a lot and fixed most of my glitches…I’d be glad to post it, but I dont know how I go about doing that\r\rAnyway I still have a few problems with it I need to work out\r\rHere is my current script\r\r\ronClipEvent (load) {\r&nbsp &nbsp &nbsp &nbsp nearnpc = “”;\r&nbsp &nbsp &nbsp &nbsp talking = false;\r&nbsp &nbsp &nbsp &nbsp pause = false;\r&nbsp &nbsp &nbsp &nbsp speed = 10;\r&nbsp &nbsp &nbsp &nbsp key_down = 0;\r&nbsp &nbsp &nbsp &nbsp s = 25;\r lock=true;\r}\ronClipEvent (keyDown) {\r&nbsp &nbsp &nbsp &nbsp this.goomba.play();\r}\ronClipEvent (keyUp) {\r&nbsp &nbsp &nbsp &nbsp key_down = 0;\r&nbsp &nbsp &nbsp &nbsp this.goomba.stop();\r}\ronClipEvent (enterFrame) {\rif(lock==true){\r&nbsp &nbsp &nbsp &nbsp if (Key.isDown(Key.UP)and key_down == 0) {\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp this._y -= speed;\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp this.gotoAndStop(“runup”);\r&nbsp &nbsp &nbsp &nbsp }\r else if (Key.isDown(Key.DOWN) and key_down == 0) {\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp this._y += speed;\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp this.gotoAndStop(“rundown”);\r&nbsp &nbsp &nbsp &nbsp }\r else if (Key.isDown(Key.LEFT) and key_down == 0) {\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp this._x -= speed;\rthis.gotoAndStop(“runleft”);\r&nbsp &nbsp &nbsp &nbsp }\r else if (Key.isDown(Key.RIGHT) and key_down == 0) {\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp this._x += speed;\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp this.gotoAndStop(“runright”);\r&nbsp &nbsp &nbsp &nbsp }\r else if (Key.isDown(Key.SPACE) and key_down == 0) {\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp this._x += 0;\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp this.gotoAndStop(“punch”);\r&nbsp &nbsp &nbsp &nbsp }\r}\r}\r\r\r\r\rNow the only problems I have left is the punch animation loops, but it has the same coiding as the other ones so Im not sure why it doesnt work and the others do\r\ralso instead of stopping in the middle of the animation when I let go of the key I want it to return to a stationary frame\r\rand I want it so after I press right the punch animation will be facing right\rand if I press left then punch he will punch left, but the same key for punch on both