Using platform services

The S60 platform allows Flash Lite applications installed on S60 mobile devices to:

The Service APIs are supported since Flash Lite Player 3.0 on S60 5th Edition devices. While you can publish your application for Flash Lite 2.0 or newer, the Service APIs only work on S60 5th Edition devices that support Flash Lite 3.0 or newer.

Using S60 Platform Services and Service APIs

Flash Lite applications use the S60 Platform Services through Service APIs. The Service APIs are supported through a Nokia-proprietary ActionScript 2.0 library. Before you can create Flash Lite applications that use platform services, you must install the library for your Flash IDE:

  1. Download the library package (ZIP) to your computer by clicking the following link:

    S60_ActionScript_API_library_1_0.zip

  2. Extract the package to the class path folder of your IDE. For example, if you are using Adobe Flash CS3 on Microsoft Windows XP, extract the package to:

    %USERPROFILE%\Local Settings\Application Data\Adobe\Flash CS3\en\Configuration\Classes\

    Make sure that the extracted ActionScript class files (.as) are located in:

    <classpath>\com\nokia\lib\

You can now create Flash Lite applications that use platform services.

Programming a Flash Lite application to access a service through its Service API involves three steps:

  1. Import the Service object from the ActionScript library for S60 Platform Services:

    import com.nokia.lib.Service;

    Alternatively, you can import the entire library:

    import com.nokia.lib.*;
  2. Create a new Service object for calling the Service API. The constructor for this object uses a service provider name and an interface name to create the appropriate service object:

    new Service(provider, interface);

    Each Service API has a service provider name and supports one interface. The service provider name identifies the Service API, while the interface defines a set of common methods for service objects.

    For example, the service provider name for the Calendar Service API is Service.Calendar and the supported interface is IDataSource. To create a Calendar service object, use the following code:

    var calendar = new Service("Service.Calendar", "IDataSource");
  3. Use the service object to call the Service API.

    For example, the IDataSource interface defines the GetList() method, which returns an object as its return value. To make a GetList() call with the Calendar service object created above, use the following code:

    var result = calendar.GetList(parameters);

For example code snippets that demonstrate how to use the platform services, see the method definitions in the ActionScript Service API reference and section Flash Lite examples.

Arguments and return values

Service API methods use ActionScript objects as arguments and return values. Argument objects can contain primitive types and other objects. Return value objects can contain primitive types, objects, arrays, and iterators. A primitive type is a string, number, or boolean. An object is a type of ActionScript object. It is a collection of properties. An array is a type of object that stores values that can be primitive types or objects. These values are accessed by indexing. An iterator is an object used to traverse through an ordered list of objects. The next() method on the iterator returns the next object in the ordered list (see the following example).

The following sample code shows how to retrieve a list of messages using the GetList() method of the Messaging Service API. The output for GetList is an object containing the ReturnValue and ErrorCode properties. ReturnValue is the iterator containing the retrieved messages.

import com.nokia.lib.Service;
var messaging = new Service("Service.Messaging", "IMessaging");
var inParams = {Type:"Inbox"};
var outParams = messaging.GetList(inParams);
if (outParams.ErrorCode == 0) {
  var outList = outParams.ReturnValue;
  var outputEntry = null;
  do {
    outputEntry = outList.next();
    if (null != outputEntry) {
      var messageType = outputEntry.MessageType;
    } else {
      break;
    }
  } while (true);