How to code ActionScript to softkey on Flash Lite Nokia Mobile App

December 21, 2009 § Leave a comment

By default you can define pressed key event to softkey using ActionScript on Flash Lite Nokia mobile app.

Flash Lite 1.1

You can assign pressed key events to a button. You can map the for navigation keys, numeric keypad, and softkeys.

Convert a shape into a button and assign the code.

on(keyPress "<Enter>") {
    trace("Selection key pressed");
}
on(keyPress "<PageUp>") {
    trace("Left softkey pressed");
}
on(keyPress "<PageDown>") {
    trace("Right softkey pressed");
}
on(keyPress "<Up>") {
    trace("Up direction key pressed");
}

Flash Lite 2.0+

A key listener can be assigned to a button, object or MovieCkip.

// Create the object for the key listener

var keyListener:Object = new Object();

// Define the onKeyDown events to listen to

keyListener.onKeyDown = function() {

    if (Key.getCode() == Key.ENTER) {

        trace("Selection key pressed");

    }

    else if (Key.getCode() == ExtendedKey.SOFT1) {

        trace("Left softkey pressed");

    }

    else if (Key.getCode() == ExtendedKey.SOFT2) {

        trace("Right softkey pressed");

    }

    else if (Key.getCode() == Key.UP) {

        trace("Up direction key pressed");

    }

}

// Enable the key listener

Key.addListener(keyListener);

To customize labels & functions for softkeys
Call the SetSoftKeys command, part of fscommand2() method on the first frame of Flash Lite app. fscommand2() command are mobile focused ActionScript, outside ActionScript library. It maps the labels to softkeys and disables the default softkey functions.

fscommand2(“SetSoftKeys”, “LeftKeyLabel”, “RightKeyLabel”);

Note: Only left and right softkeys can be coded in fscommand2 method.

Design Rules:

1. Clear label

2. Forward-going functions (continue, confirm, zoom, options, menus) should be assigned to the left softkey.

3. Backward-oriented functions (cancel, back, exit) should be assigned to the right softkey.

4. Softkey label should be rotated in position when screen orientation changes

5. Code the softkey on touch event on touch devices

Where Am I?

You are currently browsing the Flash Lite category at Web Builders.