Hi there,
I just want to ask some advise on how to change the directional arrows to keyboard letters on keypress. the browser scrolls when i press arrow up and down arrows and it’s quite annoying. i just want to change the keypress of up arrow to w, then left arrow to a, right arrow to d and down arrow to s. just one of any will do then i’ll do the rest.
here’s the code:
function detectKeys() {
var ob = _root.char;
var keyPressed = false;
if (Key.isDown(Key.RIGHT)) {
keyPressed = _root.moveChar(ob, 1, 0);
} else if (Key.isDown(Key.LEFT)) {
keyPressed = _root.moveChar(ob, -1, 0);
} else if (Key.isDown(Key.UP)) {
keyPressed = _root.moveChar(ob, 0, -1);
} else if (Key.isDown(Key.DOWN)) {
keyPressed = _root.moveChar(ob, 0, 1);
}
// walk animation
if (!keyPressed) {
ob.clip.char.gotoAndStop(1);
} else {
ob.clip.char.play();
}
}
thanks a lot!!!