I was intrigued by this question because, looking at the documentation, the Keyboard and its constants are accessible from Flash Player 9+, however, like you, I said that I cannot access AZ constants through Keyboard when targeting Flash Player 9 However, I do have access to other constants like F1 , HOME , NUMPAD_* , etc.
Once I change the version of Flash Player to 10 or higher, I can access the AZ constants.
I tried to find the reason for this, but at this point all I can assume is that the documentation is invalid and these constants are virtually inaccessible until Flash Player 10.
Fortunately, the workaround is pretty simple in this case: create your own constants for the character codes for AZ:
package { public class KeyCodes { public static const A:uint = 65; public static const B:uint = 66; public static const C:uint = 67; public static const D:uint = 68; public static const E:uint = 69; public static const F:uint = 70; public static const G:uint = 71; public static const H:uint = 72; public static const I:uint = 73; public static const J:uint = 74; public static const K:uint = 75; public static const L:uint = 76; public static const M:uint = 77; public static const N:uint = 78; public static const O:uint = 79; public static const P:uint = 80; public static const Q:uint = 81; public static const R:uint = 82; public static const S:uint = 83; public static const T:uint = 84; public static const U:uint = 85; public static const V:uint = 86; public static const W:uint = 87; public static const X:uint = 88; public static const Y:uint = 89; public static const Z:uint = 90; } }
To use this class, paste the contents into the .as file, which is in the same directory as your FLA, and then:
if(e.keyCode == KeyCodes.A)
I am trying to find the exact reason for this.
Marty source share