User Guide

Create the application (Flash Professional only) 27
11. Add the following code to handle button events for the menu buttons,
and for selection focus:
// Set initial focus when the application
// starts and also upon returning to the main
// screen from another screen.
if (selectedItem == null) {
Selection.setFocus (specials_btn);
} else {
Selection.setFocus (selectedItem);
}
// Assign onPress event handlers to each menu button,
// and set selectedItem variable to selected button
// object:
specials_btn.onPress = function () {
gotoAndStop ("specials");
selectedItem = this;
};
video_btn.onPress = function () {
gotoAndStop ("video");
selectedItem = this;
};
reservations_btn.onPress = function () {
if (location_so.data.phoneNumber == undefined) {
// User hasn't specified location so
// go to "set location" screen:
gotoAndStop ("options");
}
else {
// Call number in shared object:
var phoneNum = location_so.data.phoneNumber;
getURL ("tel:" + phoneNum);
}
selectedItem = this;
};
The onPress event handlers assigned to the buttons named
specials_btn and video_btn send the playback head to frames
labeled, respectively, “specials” and “video.” You’ll create the content for
those sections later in the tutorial (see “Create the specials screen (Flash
Professional only)” on page 29 and “Create the Video screen (Flash
Professional only)” on page 36).