Must Read

Just post!

GPS stands for Global Positioning System. GPS is a space-based satellite navigation system, which provides reliable location information to your handheld device.

If your application requires the use of the device’s GPS, you will need to select the ACCESS_FINE_LOCATION permission when you are creating your project.

Let’s review the code below. First, you will notice that there is a private variable named geoLocation declared, of type flash.sensors.GeoLocation. Within application Complete of the application, an event handler function is called, which first checks to see if the device has an available GPS unit by reading the static property of the GeoLocation class. If this property returns as true, a new instance of GeoLocation is created; the data refresh interval is set to 500 milliseconds (.5 seconds) within the setRequestedUpdateInterval method; and an event listener of type GeoLocation Event.UPDATE is added to handle updates. Upon update, the GPS information is read from the event and written to a TextArea within the handleUpdate function.

The results can be seen within Figure 4-2:

<?xml version=”1.0″ encoding=”utf-8″?>
<s:Application xmlns:fx=”″
import flash.sensors.Geolocation;
privatevar geoLocation:Geolocation;
protectedfunction application1_applicationCompleteHandler
(event:FlexEvent):void {
geoLocation = new Geolocation();
} else {
status.text = “Geolocation feature not supported”;
privatefunction handleLocationRequest(event:GeolocationEvent):void {
var mph:Number = event.speed*2.23693629;
var kph:Number = event.speed*3.6;
info.text = “Updated: ” + new Date().toTimeString() + “nn”
+ “latitude: ” + event.latitude.toString() + “n”
+ “longitude: ” + event.longitude.toString() + “n”
+ “altitude: ” + event.altitude.toString() + “n”
+ “speed: ” + event.speed.toString() + “n”
+ “speed: ” + mph.toString() + ” MPH n”
+ “speed: ” + kph.toString() + ” KPH n”
+ “heading: ” + event.heading.toString() + “n”
+ “horizontal accuracy: ”
+ event.horizontalAccuracy.toString() + “n”
+ “vertical accuracy: ”
+ event.verticalAccuracy.toString();
<!– Place non-visual elements (e.g., services, value objects) here –>
<s:Label id=”status” text=”Geolocation Info” top=”10″ width=”100%”
<s:TextArea id=”info” width=”100%” top=”40″ editable=”false”/>

GPS information

Previous articleAccelerometer
Next articleCamera UI
- Advertisement -

Latest News

Neta Auto launches tech brand “Hozon Intelligent Technology” to lead further development of intelligent EVs

On November 21, Neta Auto held a press conference in Shanghai to unveil its global technology brand "Hozon Intelligent...
- Advertisement -

More Articles Like This

- Advertisement -