×
Namespaces

Variants
Actions
Revision as of 04:37, 14 May 2013 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Archived:Geolocation in Flash Lite 4

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

We do not recommend Flash Lite development on current Nokia devices, and all Flash Lite articles on this wiki have been archived. Flash Lite has been removed from all Nokia Asha and recent Series 40 devices and has limited support on Symbian. Specific information for Nokia Belle is available in Flash Lite on Nokia Browser for Symbian. Specific information for OLD Series 40 and Symbian devices is available in the Flash Lite Developers Library.

Article Metadata
Compatibility
Platform(s):
Symbian
Symbian^3
Article
Created: manikantan (17 Oct 2010)
Last edited: hamishwillee (14 May 2013)

Contents

Introduction

With the evolution of Symbian ^3 devices in the market, Flash Lite 4 is now supported on Nokia devices. Nokia N8 is the first device from the Nokia family to support it. Flash Lite 4 is a giant leap from the prominent Flash Lite 3 paradigm and offers better performance and offers support for multi-touch, accelerometer and so on. This article concentrates on creating a simple map based application using the Geolocation API in Flash Lite 4. This code or software was built using Adobe Flash CS5 and successfully tested on Adobe Device Central CS5.

This code example is written on Actionscript 3 for Flash Lite 4 devices. In this example, we acquire GPS coordinates from the device sensors and display a Google Map of that location.


Requirements

1. Adobe Flash Toolit CS5

2. Google Maps API for Flash As3 - available at http://code.google.com/apis/maps/documentation/flash/intro.html

3. Google Maps API serial/key.


Implementation

Inside Flash CS5, create a new Flash Lite 4 document of size 360 X 425 px. Create a textfield (names locTxt) where we will display the input co-ordinates. We shall add the map element via code.


Note.pngNote: For information on using the Google Maps API for Flash in general, this is a good read. http://code.google.com/apis/maps/documentation/flash/tutorial-flash.html


In the first frame on the timeline paste,

import flash.sensors.Geolocation;
import flash.events.GeolocationEvent;
import com.google.maps.LatLng;
import com.google.maps.Map;
import com.google.maps.MapEvent;
import com.google.maps.MapType;
 
var geo:Geolocation = new Geolocation();
geo.addEventListener(GeolocationEvent.UPDATE, showLoc);
geo.setRequestedUpdateInterval(100);
var lat:Number;
var long:Number;
var map:Map = new Map();
map.key = "Your-API_KEY-goes-here";
map.sensor = "true";
map.setSize(new Point(stage.stageWidth, stage.stageHeight - 20));
map.x = 15; map.y = 15;
function showLoc(e:GeolocationEvent):void {
trace("loc info came");
locTxt.text = e.latitude.toString() + ", " + e.longitude.toString();
lat = e.latitude; long = e.longitude;
 
map.addEventListener(MapEvent.MAP_READY, onMapReady);
this.addChild(map);
}
function onMapReady(event:Event):void {
 
map.setCenter(new LatLng(lat,long), 14, MapType.NORMAL_MAP_TYPE);
}

Output

Executing this code inside Flash CS5, opens the desktop run-time Flash player which will show errors of missing Geolocation classes. Hence open the same compiled SWF inside Device Central CS5.

Ss2 geo.jpg

Testing

Device Central CS5 offers a wide range of emulation methods for Flash content on phones or devices in general. As seen in the image, there are new options in the Device Central screen. The point of focus to us here is however the ability to get GPS coordinates while testing. The one of the panels in the right (Geolocation) gives the option to send GPS co-ordinates as a signal into the emulation toolkit. Simply enter the latitude and longitude in the appropriate textfields and press SEND TO DEVICE button. This triggers an input GPS signal for the device.

Ss geo.jpg


The image below shows the network traffic monitoring panel that describes the quantity of inbound and outbound traffic.


Ss3 geo.jpg


Author

--manikantan
 07:53, 17 October 2010 (UTC)

For more tutorials from the same author

Flashactions croozeus

This page was last modified on 14 May 2013, at 04:37.
53 page views in the last 30 days.
×