如何访问活动

时间:2014-04-01 18:20:02

标签: actionscript-3 flash actionscript air geolocation

1120:访问未定义的属性事件。 如何将此事件/event.latitude.toString()/邮寄给

function onMapReady(e: Event): void {
if (Geolocation.isSupported) {
    var geo = new Geolocation();
    geo.setRequestedUpdateInterval(100);
    geo.addEventListener(GeolocationEvent.UPDATE, geolocationUpdateHandler);
}
}

function geolocationUpdateHandler(event: GeolocationEvent): void {
trace("lat:" + event.latitude.toString() + " - ");
trace("long:" + event.longitude.toString() + "° - ");
}

ve_btn.addEventListener(MouseEvent.CLICK, send);
function send(e: MouseEvent): void {
navigateToURL(new URLRequest("mailto:test@test.lv?body=</br>  latitude=" +  event.latitude.toString() + "</br>  longitude=" + event.longitude.toString()));
}

2 个答案:

答案 0 :(得分:0)

更改此部分:

function send(e: MouseEvent): void 

到此:

function send(event: MouseEvent): void 

答案 1 :(得分:0)

好的,我会试着解释一下。 如果要在某些内容上单击鼠标时使用Geolocation事件中的经度和纬度值,则需要将这些值存储在某处,因为MouseEvent没有这些属性。只有GeolocationEvent才有。

你如何解决这个问题?简单地,创建包含在geolocationUpdateHandler(...)方法中检索的纬度和经度值的变量。

像这样排序

var latitude:Number = 0;
var longitude:Number = 0;    

function onMapReady(e: Event): void {
    if (Geolocation.isSupported) {
        var geo = new Geolocation();
        geo.setRequestedUpdateInterval(100);
        geo.addEventListener(GeolocationEvent.UPDATE, geolocationUpdateHandler);
    }
    }

    function geolocationUpdateHandler(event: GeolocationEvent): void {
    trace("lat:" + event.latitude.toString() + " - ");
    trace("long:" + event.longitude.toString() + "° - ");
    latitude = event.latitude;
    longitude = event.longitude;
    }

    ve_btn.addEventListener(MouseEvent.CLICK, send);
    function send(e: MouseEvent): void {
    navigateToURL(new URLRequest("mailto:test@test.lv?body=</br>  latitude=" +  latitude.toString() + "</br>  longitude=" + longitude.toString()));
    }
相关问题