09 January 2006

Button Skema

Using Button
In Flash Lite 1.1, if we want to detect a key press (single press or continuous press), we need to attach the code to a button:
on (keyPress "") {
no += 1;
}
In Flash Lite 2, we can use back modern ActionScript, use Movie Clip or Object to do the key detection, for example:

Using Movie Clip as Key Listener
mc.onKeyDown = function() {
switch (Key.getCode()) {
case Key.UP :
no += 1;
break;
}
};
Key.addListener(mc);

Using Object as Key Listener
obj = new Object();
obj.onKeyDown = function() {
switch (Key.getCode()) {
case Key.UP :
no += 1;
break;
}
};
Key.addListener(obj);
However, using key listener has a side effect, you cannot detect continuous key press (press the key without release). If you want to detect continuous key press, you need to use an MovieClip.onEnterFrame:
mc.onEnterFrame = function() {
if (Key.isDown(Key.UP)) {
no += 1;
}
};
// Key.addListener(obj);
By the way, I find the Flash Lite 2 emulator is even worse than Flash Lite 1.1 emulator because the latter one support pressing keyboard for testing (single press or continuous press), no need to use the mouse to click the phone button.

Or you can download here

Source : http://www.luar.com.hk/flashbook/archives/001320.php

PPL IAIN Syekh Nurjati Cirebon

Jika ditanya apa yang kau suka dari kehadiran mereka? Mereka punya jawabannya : semangat yang tinggi dengan keingintahuan yang tipikal mahas...