2
我有一個函數,當用戶單擊按鈕時檢查某些東西。如果發現了某些東西,就會發出警報,說明它已經找到並詢問他們是否希望允許這種情況發生,或撤消導致發現某些事情的行爲。代碼如下所示:flex 3:將值傳遞到使用警報窗口的功能
Alert.show(thisString1, "Conflict: Multiple Projects", 3, this, conflictAnswer);
在按下「是」或「否」,則conflictAnswer函數將被調用......它看起來像這樣:
private function conflictAnswer(event:CloseEvent):void
{
if (event.detail == Alert.YES)
{
Alert.show(
}
}
我的問題是,如何我是否會傳遞顯示警報的函數中保存的一些變量?我試過這樣的事情:
Alert.show(thisString1, "Conflict: Multiple Projects", 3, this, conflictAnswer(Event, var1, var2));
private function conflictAnswer(event:CloseEvent, varA, varB):void
{
if (event.detail == Alert.YES)
{
}
}
但它沒有奏效。
有人可以幫我嗎?
感謝 惟妙惟肖
編輯 閱讀第一響應後,我想出了這一點:
answers[0] = cPositions[i][0];
answers[1] = cPositions[i][1];
var anAlert:Alert = Alert.show(thisString1, "Conflict: Multiple Projects", 3, this, conflictAnswer);
anAlert.data = {answers:Array};
然後conflictAnswer功能如下:
private function conflictAnswer(event:CloseEvent):void
{
var projectID:Number = event.currentTarget.answers[0];
var positionID:Number = event.currentTarget.answers[1];
if (event.detail == Alert.YES)
{
Alert.show(String(projectID + " | " + positionID));
}
}
但這個我沒有工作......任何想法?
我真的不知道如何使用你的迴應來幫助我。我明白你在說什麼,我只是不知道如何讓它發生。我有一個Alert.show調用...我可以在其中設置數據嗎? Alert.show顯示在原始問題中。 – Brds 2011-05-12 19:15:18
我已經添加了一個額外的行我的答案,以澄清我的意思是說「Alert.show()返回一個警報實例」:) – Constantiner 2011-05-12 19:18:25
我有幾個更多的問題...我已經添加它們下面然後編輯片原帖 – Brds 2011-05-12 19:29:01