Macromedia Flash Professional 8 UNLEASHED [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Macromedia Flash Professional 8 UNLEASHED [Electronic resources] - نسخه متنی

David Vogeleer, Eddie Wilson, Lou Barber

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید






Events of the Key Object


The keyboard is the most important way users interact with applications. It is the only way to enter pertinent information into forms. The Key object is the object that captures events associated with keyboard interaction.

Table 14.4 shows the events for the Key object.

Table 14.4. Key Events

Event Handler Methods

Action Description

onKeyDown

This event occurs when the user presses a key on the keyboard.

onKeyUp

This event occurs when the user releases the key that has been pressed.

Now that you've seen the two events associated with the Key object, here is a code example using the onKeyDown event:


//create the object to listen to the Key
var keyListen:Object = new Object();
//create the event
keyListen.onKeyDown = function(){
//trace the character you pressed
trace(String.fromCharCode(Key.getAscii()));
}
//add the listener
Key.addListener(keyListen);

The preceding code creates the listener object. Then it creates the event-handling method that includes the trace function that will send the character the user presses to the Output panel using the String object with the Key object.

Run the code, and if nothing happens at first, give the focus to the stage by clicking on it once. Then, when you use the keyboard, you should begin to see letters appearing in the Output panel.

Another object that uses events is the TextField object.

/ 318