I created a button that looks up the coordinates of the device. There is no errors in the code but for some reason which is eluding me, the event is not being triggered.
Here is my code:
protected function lblCheckIn_clickHandler(event:MouseEvent):void
{
if (Geolocation.isSupported)
{
lblLat.text = "Finding Location...";
geo.addEventListener(GeolocationEvent.UPDATE, onUpdate);
}
else
{
lblLat.text = "Geolocation is not supported on this device.";
}
}
Later on I have the event code:
protected function onUpdate(event:GeolocationEvent):void
{
if (event.horizontalAccuracy <= 10)
{
Lat = event.latitude.toString();
Long = event.longitude.toString();
lblLat.text = Lat;
lblLong.text = Long;
geo.removeEventListener(GeolocationEvent.UPDATE, onUpdate);
navigator.pushView(PersonSelect);
}
else
{
lblLat.text = "Updating";
}
}
Oh, and I also did the usual imports
import flash.filesystem.File;
import flash.sensors.Geolocation;
import flash.events.GeolocationEvent
import spark.events.ViewNavigatorEvent
import flash.utils.ByteArray;
Any clues as to why my event isnt calling?
Have you instantiated an instance of
geo
?I worked out the ultimate cause of this specific problem. It stems from Flash Builder not installing the complete Android SDK or the IOS SDK. Once I manually installed these by copying the SDK folders to their correct paths in Adobe Flash Builder, my GPS events were called successfully.
To sum up, if you get this trouble where the code and everything looks alright but it wont call up your events, then check to make sure that your latest SDKs for Flex are installed correctly for Android and or iOS