Game Development Reference

In-Depth Information

It contains the key code number of the key being pressed. The left arrow key is /3, the right arrow is

/5, the down arrow is 0,, and the up arrow is /4. You could in fact, have written the conditional state-

ments like this and they would have worked just fine:

eb$arajp*gau?k`a99
/3
%

w

lh]uan*t)9-,7

y

ahoaeb$arajp*gau?k`a99
/5
%

w

lh]uan*t'9-,7

y

ahoaeb$arajp*gau?k`a99
0,
%

w

lh]uan*u'9-,7

y

ahoaeb$arajp*gau?k`a99
/4
%

w

lh]uan*u)9-,7

y

And actually, if you want to write it this way, I won't stop you! But AS3.0's Gau^k]n` class contains

loads of predefined properties that already represent these numbers. So you don't have to memorize

the number associated with each key on the keyboard. Instead, you just need to use the Gau^k]n`

class's easy-to-read-and-remember keyboard properties:

eb$arajp*gau?k`a99
Gau^k]n`*HABP
%

w

lh]uan*t)9-,7

y

ahoaeb$arajp*gau?k`a99
Gau^k]n`*NECDP
%

w

lh]uan*t'9-,7

y

ahoaeb$arajp*gau?k`a99
Gau^k]n`*@KSJ
%

w

lh]uan*u'9-,7

y

ahoaeb$arajp*gau?k`a99
Gau^k]n`*QL
%

w

lh]uan*u)9-,7

y

In fact, the Gau^k]n` class contains a property for every key on the keyboard. If you want to

have a look at the whole list, point your web browser to dppl6++dahl*]`k^a*_ki+aj[QO+=O/H?N+

Bh]od[-,*,+;bh]od+qe+Gau^k]n`*dpih.