2014-03-31 64 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)' –