Using Geolocation with Flash Lite and Nokia Platform Services

The use of geolocation capabilities is no longer news today, we have devices with integrated GPS in cars, smartphones, notebooks etc. Flash Lite 4.0, Flash Player 10.1 (only mobile) and Adobe AIR 2.5 (also just mobile) have native support for geolocation. Flash Lite 3 can access resources geolocation smartphone using Nokia Platform Services.
Nokia has created a library especially for working with Flash Lite feature that gives access to natively are not possible as access to the accelerometer, GPS, calendar, contacts etc.

Nokia has created a library especially for working with Flash Lite feature that gives access to natively are not possible as access to the accelerometer, GPS, calendar, contacts etc.

I’ll show a simple example of the use of geolocation with Flash Lite 3.0 and Nokia Platform Services.
Download the library Nokia and then save the directory under your operating system:

Nokia Platform Services only works on devices running Symbian S60 5th.

  • Mac – Copie para /Users//Library/Application/Support/Adobe/Flash CS5/en/Configuration/Classes/
  • Windows Vista – Extraia para /Users//AppData/Local/Adobe/Flash CS4/en/Configuration/Classes.
  • Windows XP – Extraia para //Local Settings/Application Data/Adobe/Flash CS5/en/Configuration/Classes/

We will start our first example:

  • Create a file of type ActionScript 2.0 and ask them to compile for Flash Lite 3.0 or 3.1. Or you can create directly from Adobe Device Central CS5.
  • Create a MovieClip and the instance name “mcScreen” and leave the stage.

We will now part of the encoding. We start by disabling the virtual keyboard (in my case to using a Nokia 5230) and setting the program to open on fullscreen.
[ACTIONSCRIPT]
fscommand2(“DisableKeypadCompatibilityMode”);
fscommand2(“FullScreen”, “true”);
[/ACTIONSCRIPT]
Add the class to import services from Nokia and declare the needed variables.

[ACTIONSCRIPT]
import com.nokia.lib.Service

//api google maps
var API_KEY:String = “YOUR_API_KEY”;
var latitude:Number;
var longitude:Number;
var myLocation:Service;
var mapLoader:MovieClipLoader;
[/ACTIONSCRIPT]
I will use the Google Maps API to use the latitude and longitude to display the location on the map. Do I need to purchase a key Google website.
Instantiate the service and so we set the number of geolocation information from your smartphone.

[ACTIONSCRIPT]
var myLocation = new Service(“Service.Location”, “ILocation”);
var inParams = {LocationInformationClass:”GenericLocationInfo”};
var outParams = myLocation.GetLocation(inParams);
[/ACTIONSCRIPT]
Just get the latitude and longitude have to load the map. One detail is that Google has no API for working with ActionScript 2.0, ActionScript 3.0 only. So what I will do is that Flash load an image from Google Maps via HTTP. You can get details by clicking here.

[ACTIONSCRIPT]
if (outParams.ErrorCode == 0)
{
var outList = outParams.ReturnValue;
txtLatitude.text = outList.Latitude;
txtLongitude.text = outList.Longitude;
latitude = outList.Latitude;
longitude = outList.Longitude;
mcScreen.createEmptyMovieClip(“mcMap”, mcScreen.getNextHighestDepth());
mapLoader = new MovieClipLoader();
mapURL = “http://maps.google.com/maps/api/staticmap?center=”+latitude+”,”+longitude+”&size=360×640&markers=color:red|”+latitude+”,”+longitude+”&key=”+API_KEY+”&format=jpg-baseline&zoom=10&sensor=true”;
mapLoader.loadClip(mapURL, mcScreen.mcMap);
}
[/ACTIONSCRIPT]

DOWNLOAD SOURCE

To learn more:
http://www.forum.nokia.com/Develop/Other_Technologies/Flash_lite/
http://library.forum.nokia.com/index.jsp?topic=/Flash_Lite_Developers_Library/GUID-46EABDC1-37CB-412A-ACAD-1A1A9466BB68.html

Recommended Books:

Was this article helpful? feel free to make a donation and help keep the blog in the air
Flash, Flash Lite, Nokia

Leave a Reply