I want to build a top down game where the controls are the wasd buttons are for moving and the mouse click is for attacking. I done the codes for moving but im having trouble with the mouse click/attacking. When the mouse is clicked i want the attack animation played and while its playing i want the wasd buttons disabled. As soon as the attack is done i want it to straight away go to the movement part of the code. This is what i done so far
[COLOR=#444444][FONT=Calibri]package [/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]{[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]import flash.display.MovieClip;[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]import flash.events.Event;[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]import flash.events.KeyboardEvent;[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]import flash.events.MouseEvent;[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]import flash.ui.Keyboard;
[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]public class Player extends MovieClip[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]{[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]var walkSpeed:Number = 4;[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]var walkRight:Boolean = false;[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]var walkLeft:Boolean = false;[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]var walkUp:Boolean = false;[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]var walkDown:Boolean = false;[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]var attacking:Boolean = false;[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]public function Player()[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]{[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]stage.addEventListener(KeyboardEvent.KEY_DOWN , walk);[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]addEventListener(Event.ENTER_FRAME, Update);[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]stage.addEventListener(KeyboardEvent.KEY_UP, stopWalk);[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]stage.addEventListener(MouseEvent.CLICK, attack);[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]}
[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]function walk(event:KeyboardEvent)[/FONT][/COLOR][COLOR=#444444][FONT=Calibri]{[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]if (event.keyCode == 68)[/FONT][/COLOR][COLOR=#444444][FONT=Calibri]{[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]walkRight = true;[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]}[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]if (event.keyCode == 87)[/FONT][/COLOR][COLOR=#444444][FONT=Calibri]{[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]walkUp = true;[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]}[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]if (event.keyCode == 65)[/FONT][/COLOR][COLOR=#444444][FONT=Calibri]{[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]walkLeft = true;[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]}[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]if (event.keyCode == 83)[/FONT][/COLOR][COLOR=#444444][FONT=Calibri]{[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]walkDown = true;[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]}[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]}
[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]function Update(event:Event)[/FONT][/COLOR][COLOR=#444444][FONT=Calibri]{[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]var dx = parent.mouseX - x;[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]var dy = parent.mouseY - y;[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]var angle = Math.atan2(dy,dx) / Math.PI * 180;[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]rotation = angle;[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]if (walkRight == true)[/FONT][/COLOR][COLOR=#444444][FONT=Calibri]{[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]x += walkSpeed;[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]gotoAndStop(2);[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]}[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]if (walkUp == true)[/FONT][/COLOR][COLOR=#444444][FONT=Calibri]{[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]y -= walkSpeed;[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]gotoAndStop(2);[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]}[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]if (walkLeft == true)[/FONT][/COLOR][COLOR=#444444][FONT=Calibri]{[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]x -= walkSpeed;[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]gotoAndStop(2);[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]}[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]if (walkDown == true)[/FONT][/COLOR][COLOR=#444444][FONT=Calibri]{[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]y += walkSpeed;[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]gotoAndStop(2);[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]}[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]}
[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]function stopWalk(event:KeyboardEvent)[/FONT][/COLOR][COLOR=#444444][FONT=Calibri]{[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]if (event.keyCode == 68)[/FONT][/COLOR][COLOR=#444444][FONT=Calibri]{[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]event.keyCode = 0;[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]walkRight = false;[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]gotoAndStop(1);[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]}[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]if (event.keyCode == 87)[/FONT][/COLOR][COLOR=#444444][FONT=Calibri]{[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]event.keyCode = 0;[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]walkUp = false;[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]gotoAndStop(1);[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]}[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]if (event.keyCode == 65)[/FONT][/COLOR][COLOR=#444444][FONT=Calibri]{[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]event.keyCode = 0;[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]walkLeft = false;[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]gotoAndStop(1);[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]}[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]if (event.keyCode == 83)[/FONT][/COLOR][COLOR=#444444][FONT=Calibri]{[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]event.keyCode = 0;[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]walkDown = false;[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]gotoAndStop(1);[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]}[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]}[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]}[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]function attack(event:MouseEvent)[/FONT][/COLOR][COLOR=#444444][FONT=Calibri]{[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]attacking = true;[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]if (attacking == true)[/FONT][/COLOR][COLOR=#444444][FONT=Calibri]{[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]gotoAndStop('attack');[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]}[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]}[/FONT][/COLOR]
[COLOR=#444444][FONT=Calibri]}[/FONT][/COLOR]