Flash Actionscript - How to move an object using the "a, w, s, d" keys?

ralphus

New member
A= 65

s= 83

w= 87

d= 68

use it like this

if(Key.isDown(66)){
this._x=+10
}


heres some code for you to get all the ascii codes:


draw a text box on stage, set it to input text and then in the first frame put this ation script:

var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
trace("DOWN -> Code: " + Key.getCode() + "\tACSII: " + Key.getAscii() + "\tKey: " + chr(Key.getAscii()));
};
Key.addListener(keyListener);



it opens teh trace window and displays the codes of keys pressed.
 
I am trying to create a 2 player car game in flash. I have currently got the actionscript for 1 player by using the arrow keys but i am trying to get the ascii code for a,w,s,d.

For example, the code below is the code for moving left:

if(Key.isDown(Key.LEFT)){
 
Back
Top