flash - How to stop a function through another one in AS3? -


so, i'm in flash cs5 file , want disable function when running. more precise: i'm doing function makes me control game character through keyboards. when character hits one, want stop moving, if try press keys again. code:

stage.addeventlistener(keyboardevent.key_down, move) stage.addeventlistener(event.enter_frame, game)  function game(e:keyboardevent) : void {  if (e.keycode == 39){ character.x += 15; }  if (e.keycode == 37){ character.x -= 15; }  }  function game(e:event): void {  if(character.hittestobject(wall)) {  **how disable move event here??**  }  } 

i swear i've searched lot! hates bother ;)

var canwalk:boolean = true;  function game(e:keyboardevent) : void {      if (e.keycode == 39 && canwalk){         character.x += 15;     }      if (e.keycode == 37 && canwalk){         character.x -= 15;     }  }  function game(e:event): void {      if(character.hittestobject(wall)) {         canwalk = false;      }  } 

you have switch 'true' once hitaction over.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -