Thursday, April 26, 2007

Flash Lite Tutorial: The Soft Keys (Flash Lite 1.1)

The Soft Keys (Flash Lite 1.1)


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 ""){
//do your action here
}

Remember in Flash 1.1, left soft key refers to , and right soft key refers to .

No comments: