0
我非常確定eval不以這種方式工作,但它可以實現這個想法。我試圖動態創建全局變量;這裏是我的代碼:如何動態創建_global變量?喜歡:_global.eval(「var」+ i)
var ti_arr:Array = new Array;
_global.a = new Object;
for (var t=0; t<group_count-1; t++) {
numOfItems = group_nodes[t].childNodes.length;
ti_arr = "tab_info" add t;
// <-- I want to define a global array with the name held in ti_arr here
for (var i=0; i<numOfItems; i++) {
eval(ti_arr)[i].a.name = tempNode.attributes.name; //<-- or give the array global scope here
eval(ti_arr)[i].a.value = tempNode.attributes.value;
}
}
我需要:tab_info1.a.name具有全局範圍。
最終,我只需要動態創建一個全局數組並分配值。我應該以不同的方式解決問題嗎? – integris