flash animation video tutorials

 

 

 

START LEARNING
FLASH NOW

Get instant access to over
45 minutes of FREE Flash tutorials on video
 and our newsletter.

Name:
E-Mail:
Phone:
Describe

.

.

.

 
Web video-animation.com

.

.

flash tutorials flash tutorials flash tutorials flash tutorials

Flash 8 Keycodes keyListener

I have just found all my keycodes for the key strokes on the keyboard for flash 8. Using the numbers is a lot easier than trying to suss out what the proper code is for using a particular letter or number key. This is useful for games for controlling the characters or cars or for a fighting game like i used in my fighting bananas game . In that game i did not use a keyListener which is a much better way of doing things. I will show you one later and how to use it. It is a lot better and simpler than what I had done back in those dinosaur days. The way that I did it is not the best way to do it. I have used clipEvents on the movieclips which is a bad idea and also I have used an onEnterFrame loop which is constantly looping waiting for a keystroke. The listener is much better and saves heaps of resources.

Flash Tutorials in Video Format - Watch them now at LearnFlash.com  

Now for the keycodes. Wait for it , it is a long list:

Letters
A - 65
B - 66
C - 67
D - 68
E - 69
F - 70
G - 71
H - 72
I - 73
J - 74
K - 75
L - 76
M - 77
N - 78
O - 79
P - 80
Q - 81
R - 82
S - 83
T - 84
U - 85
V - 86
W - 87
X - 88
Y - 89
Z - 90

Numbers
0 - 48
1 - 49
2 - 50
3 - 51
4 - 52
5 - 53
6 - 54
7 - 56
8 - 57
9 - 58

Here is an example of a keyListener and how you can use the ascii keycodes in Flash Actionscript programming:



// key listener..

 keyListener = new Object(); // make key listener object
 // this function gets triggered whenever a key is pressed
 keyListener.onKeyDown = function() {
        var keyCode = Key.getCode(); // get the key code
 
         if (keyCode == 87) { // W 
                // do something
	blah_mc._alpha -= 10;
		     }
        } else if (keyCode == 83) { // S
               // move car left
	car_mc._x -= 10;
                }
        } else if (keyCode == 68) { // D
    car_mc.gotoAndStop(3);
         }
 };
Key.addListener(keyListener); // notify Key object about your listener


Flash 8 keycode Resources

banana fighting game
Capturing Key events - old skool
Actionscript OOP game
Post about moving a cube around

.

flash 8