因爲當使用sql lite如果你嘗試並在同一時間做一個函數它會引發一個錯誤,即時只是試圖做一個函數,將檢查它的執行,如果它是在10毫秒內再次嘗試,這個確切的函數工作正常,如果我不必傳遞任何參數的功能,但我很困惑,我可以通過瓦爾回到它將執行的功能。如何將參數傳入flex/actionscript中的事件偵聽器函數?
我想做的事:
timer.addEventListener(TimerEvent.TIMER, saveChat(username, chatBoxText));
但只會讓我做:
timer.addEventListener(TimerEvent.TIMER, saveChat);
它給了我這個編譯錯誤:
1067: Implicit coercion of a value of type void to an unrelated type Function
我怎樣才能得到這是爲了通過這個限制?
下面是我得到了什麼:
public function saveChat(username:String, chatBoxText:String, e:TimerEvent=null):void
{
var timer:Timer = new Timer(10, 1);
timer.addEventListener(TimerEvent.TIMER, saveChat);
if(!saveChatSql.executing)
{
saveChatSql.text = "UPDATE active_chats SET convo = '"+chatBoxText+"' WHERE username = '"+username+"';";
saveChatSql.execute();
}
else timer.start();
}
鏈接無法工作 – Kukeltje