Форум Flasher.ru

Форум Flasher.ru (http://www.flasher.ru/forum/index.php)
-   ActionScript 3.0 (http://www.flasher.ru/forum/forumdisplay.php?f=83)
-   -   прослушивание клавиш (http://www.flasher.ru/forum/showthread.php?t=132236)

engineer_f_R 07.11.2009 10:42

прослушивание клавиш
 
сделал класс для прослушивания нажатия и отпускания клавиш.

функция перехвата нажатия кнопки выглядит так:
Код AS3:

public function F_key_down(a:KeyboardEvent):void{
 
        var V_key_press_code:int = a.keyCode;
 
            if(V_key_press_code == Keyboard.RIGHT)
        {
 
        }

после проверки компилятор далуется на:
1120: Access of undefined property Keyboard.

что я делаю не так? =)

bicubic_bublic 07.11.2009 11:44

Цитата:

Сообщение от engineer_f_R (Сообщение 863968)
что я делаю не так? =)

Возможно, Вы забыли написать
Код AS3:

import flash.ui.Keyboard;


sergeyne 07.11.2009 17:37

если всё же не сработает, то укажите код клавиши напрямую- стрелка вправо 39.
V_key_press_code == 39

Felicast 07.11.2009 20:45

Цитата:

Сообщение от sergeyne (Сообщение 864010)
если всё же не сработает, то укажите код клавиши напрямую- стрелка вправо 39.
V_key_press_code == 39

это плохой путь. лучше через константы

Ixanezis 23.01.2010 17:07

Вот и я считал, что это плохой путь. Но что-то не могу никак сделать по-хорошему, потому что Keyboard.LEFT работает например, а вот Keyboard.A - никак. Не компилируется такой код.

udaaff 23.01.2010 17:20

Код AS3:

package by.typing.utils
{
        import flash.ui.Keyboard;
 
        /**
        * @author Vitalik Sosnovski
        */
       
        public class MyKeyboard
        {
 
                public static const BACKSPACE:uint = 8;
                public static const TAB:uint = 9;
                public static const ENTER:uint = 13;
                public static const SHIFT:uint = 16;
                public static const CONTROL:uint = 17;
                public static const CAPS_LOCK:uint = 20;
                public static const ESC:uint = 27;
                public static const SPACE:uint = 32;
 
                public static const NUMBER_0:uint = 48;
                public static const NUMBER_1:uint = 49;
                public static const NUMBER_2:uint = 50;
                public static const NUMBER_3:uint = 51;
                public static const NUMBER_4:uint = 52;
                public static const NUMBER_5:uint = 53;
                public static const NUMBER_6:uint = 54;
                public static const NUMBER_7:uint = 55;
                public static const NUMBER_8:uint = 56;
                public static const NUMBER_9:uint = 57;
 
                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;
 
                public static const SEMICOLON:uint = 186;
                public static const EQUAL:uint = 187;
                public static const COMMA:uint = 188;
                public static const MINUS:uint = 189;
                public static const PERIOD:uint = 190;
                public static const SLASH:uint = 191;
                public static const BACKQUOTE:uint = 192;
 
                public static const LEFTBRACKET:uint = 219;
                public static const BACKSLASH:uint = 220;
                public static const RIGHTBRACKET:uint = 221;
                public static const QUOTE:uint = 222;
 
 
 
                public static function get capsLock():Boolean
                {
                        return Keyboard.capsLock;
                }
 
                public static function get numLock():Boolean
                {
                        return Keyboard.numLock;
                }
 
                public static function isAccessible():Boolean
                {
                        return Keyboard.isAccessible();
                }
 
        }
}


Ixanezis 23.01.2010 18:06

Хм, спасибо, как раз начал писать аналогичный класс :)

Psycho Tiger 23.01.2010 19:32

Спасибо за класс, утащу себе.


Часовой пояс GMT +4, время: 12:50.

Copyright © 1999-2008 Flasher.ru. All rights reserved.
Работает на vBulletin®. Copyright ©2000 - 2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Администрация сайта не несёт ответственности за любую предоставленную посетителями информацию. Подробнее см. Правила.