Flash CS3 Documentation |
|||
| Getting Started with Flash Lite 2.x > Tutorial: Creating a Flash Lite Application > Create the application > Create the specials screen > Add navigation and text to the specials screen | |||
In this section, you'll add interactivity to the specials screen that lets the user control the transition between each animation. You'll also add dynamic text fields that display the name and description of each image.
This text field displays the name of the special whose image is shown on the screen.
stop();
fscommand2("SetSoftKeys", "Home", "Next");
title_txt.text = "Summer salad";
description_txt.text = "Butter lettuce with apples, blood orange segments, gorgonzola, and raspberry vinaigrette.";
This code displays the name description of the first special in the two dynamic text fields. It also stops the playhead on the current frame, and registers the device's soft keys.
stop(); title_txt.text = "Chinese Noodle Salad"; description_txt.text = "Rice noodles with garlic sauce, shitake mushrooms, scallions, and bok choy.";
stop(); title_txt.text = "Seared Salmon"; description_txt.text = "Filet of wild salmon with caramelized onions, new potatoes, and caper and tomato salsa.";
stop(); title_txt.text = "New York Cheesecake"; description_txt.text = "Creamy traditional cheesecake served with chocolate sauce and strawberries.";
gotoAndStop("specials");
This code returns the playhead to the beginning of the animation sequence. The first and last images in the animation sequence are the same, which creates the illusion of a continuous animation.
Next you'll add navigation to the specials screen that lets the user navigate between images and descriptions of each special.
Key.removeListener (myListener);
var myListener:Object = new Object ();
myListener.onKeyDown = function () {
var keyCode = Key.getCode ();
if (keyCode == ExtendedKey.SOFT1) {
// Handle left soft key event
gotoAndPlay ("home");
}
else if (keyCode == ExtendedKey.SOFT2) {
// Handle right soft key event
play ();
description_txt.text = "";
title_txt.text = "";
}
};
Key.addListener (myListener);
The left soft key sends the playhead to the main application screen, and the right soft key advances the image animation to the next image in the sequence.
For more information about using event listeners, see Using a key listener to handle keypress events in Developing Flash Lite 2.x Applications.
Flash CS3