Archived:Keypressイベントを処理する方法
Archived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.
We do not recommend Flash Lite development on current Nokia devices, and all Flash Lite articles on this wiki have been archived. Flash Lite has been removed from all Nokia Asha and recent Series 40 devices and has limited support on Symbian. Specific information for Nokia Belle is available in Flash Lite on Nokia Browser for Symbian. Specific information for OLD Series 40 and Symbian devices is available in the Flash Lite Developers Library.
We do not recommend Flash Lite development on current Nokia devices, and all Flash Lite articles on this wiki have been archived. Flash Lite has been removed from all Nokia Asha and recent Series 40 devices and has limited support on Symbian. Specific information for Nokia Belle is available in Flash Lite on Nokia Browser for Symbian. Specific information for OLD Series 40 and Symbian devices is available in the Flash Lite Developers Library.
Article Metadata
Compatibility
Platform(s): Flash Lite: 1.1, 2.x
Article
Translated:
By morisawafnj
Last edited: hamishwillee
(14 May 2013)
onハンドラを使用したkeypressイベントの処理
keypressイベントを処理する方法の一つは、下記の記述を使うことです。
on(keyPress aKeyCode) {A command handling code}
下記のコード例は、"Up"キーと"9"キーのkeypressイベントを処理する方法を示しています。
- テキストツールを使用し、静止テキストフィールドをドキュメントの外にドラッグします。
- このテキストをボタンに変更します: テキストフィールドを選択 → 右クリック → シンボルに変換 → ボタンを選択
- アクションパネルを開き、以下のコードを追加します:
on(keyPress "<Up>")
{
trace("You have pressed the Up key");
//Add your command handling code here
}
on(keyPress "9")
{
//Add your command handling code here
}
キー定数一覧
ソフトキーを処理するために、最初にSetSoftKeysコマンドを呼ぶ必要があります。
| 端末のキー | Keypressコード |
| 0-9, *, # | 0-9, *, # |
| 左矢印キー | <Left> |
| 右矢印キー | <Right> |
| 上矢印キー | <Up> |
| 下矢印キー | <Down> |
| 選択キー | <Enter> |
| 左ソフトキー | <PageUp> |
| 右ソフトキー | <PageDown> |
キーリスナーを使用したkeypressイベントの処理(Flash Lite 2.x以降のみ)
//Create a listener object named keyListener
var keyListener:Object = new Object();
//Define a function that responds to the KeyDown event
keyListener.onKeyDown = function()
{
if (Key.getCode() == Key.UP)
{
trace("You have pressed the Up key");
//Add your command handling code here
}
else
{
trace("You have pressed: "+Key.getCode());
}
};
//The keyListener object is then registered to the Key object
Key.addListener(keyListener);
キーリスナーを使用してソフトキーを処理する方法は、Flash Lite 2.0のソフトキーを使用した例題をご参照ください。



(no comments yet)