Tuesday, 13 March 2007

The Soft Keys (Flash Lite 1.1)

In the previous tutorial, How To Detect Button Presses. I didn't really cover much about the soft keys. The soft keys, on most phones, refer to the top left and right unlabelled buttons on your phone:

These buttons are especially useful in navigation and would seem logical to include these in menu selection. Traditionally, the left soft key in a menu selects and activates that menu, while the right soft key exits the menu system. However with more advanced cellphones with keyboard functions, there can be more than 2 soft keys. We will take a look into how this is done.

First off, we need to look at two pieces of code:

FSCommand2("setSoftKeys", soft1, soft2);

This is an fscommand2() function, which contrasting fscommand() is immediately gets activated without waiting for the frame to end. This command needs to be at the beginning of your flash file for your soft keys to be operable. The variables soft1 and soft2 represents the labels you will have on your keys (shown at the bottom left and right side of your screen). Thus, for your menu, if you want the left button labelled Select and right button labelled Exit, you would do this:

FSCommand2("setSoftKeys", "Select","Previous");

Now you have another decision to consider, do you want your flash file to be fullscreen? There are two ways around this:

a) Yes! I want fullscreen!
You will need this piece of code:

FSCommand2("fullscreen", "true");

Here's the added bonus: you will see the labelled buttons appear at the bottom (via your first line). That is to say, you'd see Select and Previous labels.

b) No, no fullscreen!
This is acceptable as well, the flash still shows fullscreen (*I'm referring to implementing menus here, not just swf files - if you're just viewing a swf file, it will not be fullscreen in this instance). However, only a left label that says "Select" will be shown. Although your soft keys will be functional, you will not see the assigned labels you used. In this method, you will also need to allocate some room at the bottom movie to accomodate for the label. Or else, that "Select" label will overlap anything you have there.

And lastly, now that we have that sorted out, you're ready to use your soft keys!

on(keyPress "<PageUp>"){
//do your action here

Remember in Flash 1.1, left soft key refers to <PageUp>, and right soft key refers to <PageDown>.


Alessandro said...


I always use the following:
FSCommand2("setSoftKeys", "Select","Previous");
FSCommand2("setSoftKeys", "", "");

and then take care of labels in FL

Lee said...

Hi, Can you please tell me, if possible, how you can delete/remove "select" on a flash menu?! As I have an iPhone theme and it looks ruined with a big "SELECT" Button on it!

Phil said...

Did you try what alessandro mentioned above?

FSCommand2("setSoftKeys", "", "");