Flash CS3 Documentation |
|||
| Developing Flash Lite 1.x Applications > Creating Interactivity and Navigation > Using the soft keys | |||
A device's soft keys are multifunctional keys that use the device's display to identify their purpose at any moment. For example, in the following application, labels above the soft keys indicate that the user can press the Right soft key to view the next dinner special, or press the Left soft key to return to the application's home screen:
To use the Left and Right soft keys, you must first call the SetSoftKeys command (see SetSoftKeys in Flash Lite 1.x ActionScript Language Reference). Subsequently, Flash Lite generates a PageDown event when the user presses the Right soft key and a PageUp event when the user presses the Left soft key. You write ActionScript event handler code that responds to these events and takes the desired action.
The SetSoftKeys command takes two parameters that specify the labels for the Left and Right soft keys, respectively, that appear when your application is not running in full-screen mode. For applications running in full-screen mode, the labels that you specify are not visible, so you must create your own labels and position them on the Stage where the soft keys are located.
For example, consider the following SetSoftKeys command call:
fscommand2("SetSoftKeys", "Options", "Exit");
The following image shows the result of this command on an application running on an actual device in normal (not full-screen) mode:
If you enable full-screen mode--that is, if you call fscommand("fullscreen", true)--the labels that you specify as parameters to the SetSoftKeys command are not visible. Consequently, in full-screen mode applications, you must create your own soft key labels, as the following image shows:
For more information about device templates, see Using Flash Lite document templates.
This text field displays a message when you run the application and press the Left and Right soft keys. Your document's Stage should look like the following image:
|
NOTE |
|
In a real-world application, you might want to use something other than ordinary text fields for the soft key labels, such as graphic or movie clip symbols. |
// Handle Left soft keypress event
on(keyPress "<PageUp>") {
status = "You pressed the Left soft key.";
}
// Handle Right soft keypress event
on(keyPress "<PageDown>") {
status = "You pressed the Right soft key.";
}
fscommand2("SetSoftKeys", "Left", "Right");
fscommand2("FullScreen", true);
The two parameters of the SetSoftKeys command--Left and Right, in this case--specify the labels that Flash Lite displays above the soft keys when the application is not being viewed in full-screen mode. In this case, the application uses the FullScreen command (see FullScreen in Flash Lite 1.x ActionScript Language Reference) to force the application to display in full-screen mode. Consequently, the values you choose for those parameters can be arbitrary text strings or expressions.
fscommand2("SetSoftKeys", foo, bar);
Click the Left and Right soft keys with your mouse, or press the Page Up and Page Down keys on your keyboard to test the application.
Flash CS3