Flex中的地理位置没有触发事件 [英] Event is not being triggered for Geolocation in Flex

查看:209
本文介绍了Flex中的地理位置没有触发事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个查看设备坐标的按钮。代码中没有错误,但由于某些原因,这是我逃避事件不被触发。

这是我的代码:

  protected function lblCheckIn_clickHandler(event:MouseEvent):void 
{
if(Geolocation.isSupported)
{
lblLat.text =查找位置...;
geo.addEventListener(GeolocationEvent.UPDATE,onUpdate);





lblLat.text =此设备不支持地理定位。


后来我有事件代码:

  protected function onUpdate(event:GeolocationEvent):void 
{
if(event.horizo​​ntalAccuracy <= 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 =正在更新;


$ / code $ / pre
$ b $噢, p>

  import flash.filesystem.File; 
import flash.sensors.Geolocation;
import flash.events.GeolocationEvent
import spark.events.ViewNavigatorEvent
import flash.utils.ByteArray;

任何线索为什么我的事件没有调用?

解决方案

我找出了这个特定问题的根本原因。它源于Flash Builder,不会安装完整的Android SDK或IOS SDK。一旦我通过在Adobe Flash Builder中将SDK文件夹复制到正确的路径来手动安装这些文件,我的GPS事件就被成功调用了。



总之,如果你遇到这个麻烦代码和一切看起来不错,但它不会调用你的事件,然后检查,以确保您的最新SDK的SDK安装正确的Android和/或iOS的


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?

解决方案

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

这篇关于Flex中的地理位置没有触发事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆