是否可以在对象实例名称中获取包含变量的对象的子对象?对象名称中的变量
location_1
,location_2
是包含hidden_1
,hidden_2
管委会等
MCS和我非常喜欢里面增加整数for循环为目标的隐藏的对象。我已经去除了for循环易于阅读下面的:
var i = 0;
var cacheNum = 0;
var locMc = this["location_"+(i+1)]; // This works
var hiddenMc = locMc.this["hidden_"+(cacheNum+1)]; // This doesn't work!
我最想要的是可能是:
var i = 1;
var cacheNum = 1;
var hiddenMc = location_i.hiddenMc_cacheNum;
非常感谢, 尼克
取出'this'。但是为什么当数组更容易处理时,你想这样做呢? – David 2013-02-08 17:23:57
loc_mc [“location_1”] [“hidden_1”]是否存在? – 2013-02-08 17:24:13
'location_1'是一个包含'hidden_1','hidden_2'等的MC。请看清晰的问题 - 应该更清楚。 – 2013-02-08 17:26:18