Flash CS3 Documentation |
|||
| Developing Flash Lite 1.x Applications > Creating Interactivity and Navigation > Handling button events | |||
Flash Lite supports the following ActionScript button events: press, release, rollOver, and rollOut. To handle these events, you attach an on(event) handler to a button instance, where event is one of the supported button events listed in the following table:
|
Button event |
When event is generated |
|---|---|
press
|
User presses the Select key on device when button has focus. |
release
|
User releases the Select key on device when button has focus. |
rollOver
|
Button receives focus. |
rollOut
|
Button loses focus. |
The following procedure demonstrates how to create a simple application that handles button events. For an example of using buttons to create a menu, see Creating a simple menu using buttons and tab navigation.
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(press) {
trace("You pressed Button 1");
}
on(release) {
trace("You released Button 1");
}
on(rollOver) {
trace("Button 1 has focus");
}
on(rollOut) {
trace("Button 1 lost focus");
}
on(press) {
trace("You pressed Button 2");
}
on(release) {
trace("You released Button 2");
}
on(rollOver) {
trace("Button 2 has focus");
}
on(rollOut) {
trace("Button 2 lost focus");
}
_focusRect = false;
This disables the yellow focus rectangle that Flash Lite draws around the button with focus. In this case, the default focus rectangle is unnecessary because the button's contains an Over state that is displayed when it has focus.
The emulator displays messages as you press the Up and Down Arrow keys on the keypad.
Flash CS3