Problems with Key.isDown

Commenta 3rd January , 2010
I’m currently creating a short interactive flash for a coursework submission, but I’m having trouble with actionscripting as I’m very new to it, and the code my tutor has supplied doesn’t work.

I have a character with multiple animations by way of movieclips, and I’m trying to have it move using the Key.isDown function.

Now, my character is moving correctly, but when the key is released, the animation keeps playing. I tried adding a stop command at the end of the walkcycle animation, but that just causes the character to stay frozen on the last frame of the cycle.

Help please?

Here is the code I’m currently using:

ActionScript Code:
onClipEvent(load) { var direction = "left"; var speed = 2; } onClipEvent(enterFrame) { if(Key.isDown(Key.LEFT)){ this.direction = "left"; this._x -= speed; this.gotoAndStop('WalkLEFT'); } else if(Key.isDown(Key.RIGHT)) { this.direction = "right"; this._x += speed; this.gotoAndStop('WalkRIGHT'); } else { this.gotoAndStop('wait'+this.direction); } }

Thanks in advance!
-Kikii

Original post by KikiiMcI

Lascia un Commento