2014-03-31 63 views
0

广东话发送消息trought当按下按钮广东话发送消息trought当按下按钮

当它被GPS坐标发送每一次电子邮件,但按钮不起作用单击

类型错误:错误#1034:类型强制失败:无法将flash.events::[email protected]转换为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:[email protected]?body=</br> latitude=" + event.latitude.toString() + "</br> longitude=" + event.longitude.toString())); 
} 
+0

参数事件:的MouseEvent在VE(...)方法没有一个叫GeolocationEvent属性或方法,这样你就可以不写“event.GeolocationEvent()”,因为它不存在。 – DodgerThud

+0

我现在做了一些修改 ve_btn.addEventListener(MouseEvent.CLICK,fl_UpdateGeolocation_2); – user3332885

+0

但问题是当它得到的坐标它自动发送邮件,但我只需要它在鼠标点击 – user3332885

回答

1

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

ve_btn.addEventListener(MouseEvent.CLICK, onClick); 

function onClick(e: MouseEvent):void{ 
    //Get last location and mail it 
} 
+0

它不起作用TypeError:错误#1034:类型强制失败:无法将flash.events::[email protected]转换为flash.events.GeolocationEvent。 – user3332885

+0

也许你有一些聪明的想法? – user3332885

+0

因为这是不正确的've_btn.addEventListener(MouseEvent.CLICK,fl_UpdateGeolocation_2)' –