Flash CS3 Documentation |
|||
| Developing Flash Lite 1.x Applications > Creating Interactivity and Navigation > Handling key events > Creating a key catcher button | |||
If your application must handle several different keypress events you could either create a single button for each keypress event, or use a single button to handle all keypress events. This type of button is commonly called a key catcher (or key listener) button. Because the key catcher button isn't supposed to be visible to the user, it usually sits off the Stage (in the work area).
The following procedures demonstrate how to use a key catcher button to handle keypress events in a simple application. The application lets the user move a circle around the Stage by pressing the four arrow keys on their device.
For more information on creating documents from the Flash Lite templates, see Using Flash Lite document templates in Getting Started with Flash Lite 1.x.
on(keyPress "<Left>") {
circle._x -= 10;
}
on(keyPress "<Right>") {
circle._x += 10;
}
on(keyPress "<Up>") {
circle._y -= 10;
}
on(keyPress "<Down>") {
circle._y += 10;
}
Press the four arrow keys on the keypad of the Adobe Device Central emulator to make the circle move around the Stage.
For another example of using a key catcher button, see Creating a simple menu using movie clips.
Flash CS3