ActionScript three senior goals not working?

This code works fine in actionscript 3 when my goal is 10.3 and above, but when my goal is Flash Player 9, it gives me a Scene 1 error,

Layer 'Layer 1', Frame 1, Line 7 1119: Access to a possible undefined L property through a link with a static class type.

Does anyone know how I can fix this so that it works in flash player 9? Have I already tried changing the keyboard (keycode #) and even trying it with apparently syntax of the flash player syntax 9? but everything I tried fails. I can not find a solution on the Internet, who has any ideas? thanks

var lDown:Boolean = false; var sDown:Boolean = false; var dDown:Boolean = false; stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyBoardDown); function onKeyBoardDown(e:KeyboardEvent):void { if (e.keyCode == Keyboard.L) { lDown = true; } if (lDown == true) { if (e.keyCode == Keyboard.S) { sDown = true; } } if (sDown == true) { if (e.keyCode == Keyboard.D) { dDown = true; } } if (dDown == true) { trace("ehhh"); } } 
+5
source share
1 answer

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) // etc 

I am trying to find the exact reason for this.

+3
source

Source: https://habr.com/ru/post/1205120/


All Articles