Showing posts with label Button. Show all posts
Showing posts with label Button. Show all posts

Wednesday, April 05, 2006

Flash Lite [20] 2.0 Button event

在Flash Lite 2.0中,我們要用跟1.1不同的方式來偵測並控制Button event

如果要使用手機上左右兩顆軟體鍵,要加入下面的程式
fscommand2(”SetSoftKeys”, “Left”, “Right”);

接下來我們需要一個keyLinstener的物件,來偵測Button event

var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
if (Key.getCode() == ExtendedKey.SOFT1) {
//Left Softkey
} else if (Key.getCode() == ExtendedKey.SOFT2) {
//Right Softky
} else if (Key.getCode() == Key.LEFT) {
} else if (Key.getCode() == Key.RIGHT) {
} else if (Key.getCode() == Key.UP) {
} else if (Key.getCode() == Key.DOWN) {
} else if (Key.getCode() == Key.ENTER) {
}
};
Key.addListener(keyListener);

如果要使用0-9的數字鍵,我們要用getAcsii(),對應的號碼為48-57
“*” 是43
“#” 是35

【注意】不要使用getCode()來偵測數字鍵,因為對應的號碼有重複的狀況,3=#, 8=*

Wednesday, July 27, 2005

Flash Lite [ 2 ] Button event

上次有提到,在Flash Lite裡面,要偵測按鍵的行為,
必須透過Button來偵測。

下面是Flash Lite裡面幾個已經定義好的按鍵:
on (keyPress "<指定的按鍵>"){ }
上下左右鍵: Up / Down / Left / Right
左邊功能鍵: PageUp
右邊功能鍵: PageDown
確定鍵: Enter
撥號鍵(Send): Home

Off鍵: End
數字鍵: on (press, keyPress "1") { }
米字鍵: on (press, keyPress " * ") { }
井字鍵: on (press, keyPress " # ") { }

其他需要控制的按鍵,就需要底層的支援,只要定義好就可使用
例如: 返回鍵、清除鍵、音量控制鍵、拍照鍵等...用法就跟數字鍵相同