我試圖創建一個for循環,做同樣的事情,因爲這代碼(任務是數組):for循環轉換一系列變量
Quest0.text = quests[0]
Quest1.text = quests[1]
Quest2.text = quests[2]
Quest3.text = quests[3]
Quest4.text = quests[4]
Quest5.text = quests[5]
Quest6.text = quests[6]
Quest7.text = quests[7]
Quest8.text = quests[8]
Quest9.text = quests[9]
Quest10.text = quests[10]
Quest11.text = quests[11]
Quest12.text = quests[12]
Quest13.text = quests[13]
Quest14.text = quests[14]
Quest15.text = quests[15]
到目前爲止,我的一切是這(activeQuests是陣列任務的長度):
var q = 0;
for (q=0; q <= activeQuests; q++) {
Quest0.text = quests[q]
}
但我不知道如何得到它做休息。
可能要添加一個參考.. http://www.i-marco.nl/weblog/archive/2007/06/14/variable_variables_in_javascri – amosrivera 2012-01-04 08:23:01
@amosrivera:謝謝,補充說我的答案。 – bobbymcr 2012-01-04 08:44:31