我将要和你一起分享一些代码,这是一个在flash.sensors 包中的新API,叫Geolocation.这个包可以轻松的运用在Flash Pro Cs5创建的应用,以及FL4和AIR中。
你可以在 Device Central Cs5 中的设备上测试你的应用,你将会感觉到非常酷。
import flash.sensors.Geolocation; import flash.events.GeolocationEvent;
var locale:Geolocation = new Geolocation(); locale.setRequestedUpdateInterval(5000); locale.addEventListener(GeolocationEvent.UPDATE, onlocationHandler);
function onlocationHandler(e:GeolocationEvent):void{
lastLat = e.latitude; lastLon = e.longitude; gpsIcon_mc.visible = !gpsIcon_mc.visible;
}
翻译来自9RIA
|