Wednesday, April 05, 2006

Flash Lite [20] 2.0 Button event

In the Flash Lite 2.0, we have to use different way to access the button event.

First, if you need to use the softkeys, you have to write down the code as below to enable it.
fscommand2(”SetSoftKeys”, “Left”, “Right”);

Then we need a KeyLinstener:Object to access the button event and define the behavior.

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);

If you would like to define the numeric keys(0-9), you need to use the Key.getAscii() start from 48 to 57.
use 43 to define the “*”
use 35 to define the “#”

[ Notice ] Don’t use getCode() for numeric keys, because the keyCode of 3=# and 8=*.