To create a simple menu using buttons and default navigation, you need to design the menu and then write event handling code for it. To create the menu, you'll use three button symbols, one for each menu option. Then you'll write event handling code that displays a message when the user rolls over each menu item--that is, when the user gives focus to the corresponding button--and when the user selects the menu item by pressing the select key on the device. For more information about handling button events in Flash Lite, see Handling button events.
Start with a partially completed Flash document. You can change these settings to target a different device and content type (see Using the emulator).
Notice that the Library contains three button symbols named News Button, Weather Button, and Sports Button.
This text field displays a short message when the user rolls over each menu item.
The Stage should look something like the following image:
// Disable the focus rectangle because buttons have an over state
_focusRect = false;
btn_news.onRollOver = function() {
txt_status.text = "Press to select News";
}
btn_news.onPress = function() {
txt_status.text = "You selected News";
}
btn_sports.onRollOver = function() {
txt_status.text = "Press to select Sports";
}
btn_sports.onPress = function() {
txt_status.text = "You selected Sports";
}
btn_weather.onRollOver = function() {
txt_status.text = "Press to select Weather";
}
btn_weather.onPress = function() {
txt_status.text = "You selected Weather";
}
Click the down arrow key on the emulator with your mouse (or press the down arrow key on your computer's keyboard) to navigate between menu options; to select a menu item, click the emulator's select key by using your mouse (or press the Enter key on your computer's keyboard).