按下按钮时无法发送消息

时间:2014-03-31 07:12:19

标签: actionscript-3 flash air geolocation adobe

按下按钮时无法发送消息

当它获得gps坐标时,它每次都会发送电子邮件,但不会按下按钮

TypeError:错误#1034:类型强制失败:无法将flash.events::MouseEvent@6d6a6d1转换为flash.events.GeolocationEvent。

ve_btn.addEventListener(MouseEvent.CLICK, fl_UpdateGeolocation_2);

var fl_GeolocationDisplay_2:TextField = new TextField();
fl_GeolocationDisplay_2.autoSize = TextFieldAutoSize.LEFT;
fl_GeolocationDisplay_2.text = "Geolocation is not responding. Verify the device's    location settings.";
addChild(fl_GeolocationDisplay_2);

if(!Geolocation.isSupported)
{
fl_GeolocationDisplay_2.text = "Geolocation is not supported on this device.";
}
else
{
var fl_Geolocation_2:Geolocation = new Geolocation();
fl_Geolocation_2.setRequestedUpdateInterval(1000);
fl_Geolocation_2.addEventListener(GeolocationEvent.UPDATE, fl_UpdateGeolocation_2);
}

function fl_UpdateGeolocation_2(event:GeolocationEvent):void
{
fl_GeolocationDisplay_2.text = "latitude: ";
fl_GeolocationDisplay_2.appendText(event.latitude.toString() + "\n");
fl_GeolocationDisplay_2.appendText("longitude: ");
fl_GeolocationDisplay_2.appendText(event.longitude.toString() + "\n");
fl_GeolocationDisplay_2.appendText("altitude: ");
fl_GeolocationDisplay_2.appendText(event.altitude.toString() + "\n");
navigateToURL(new URLRequest("mailto:test@test.lv?body=</br>  latitude=" +    event.latitude.toString() + "</br>  longitude=" + event.longitude.toString()));
}

1 个答案:

答案 0 :(得分:1)

您不能对不同类型的事件使用相同的事件处理程序。虽然地理位置适用于GeolocationEvent,但您尝试将MouseEvent传递给同一个事件侦听器。

ve_btn.addEventListener(MouseEvent.CLICK, onClick);

function onClick(e: MouseEvent):void{
    //Get last location and mail it
}
相关问题