我无法动态地使用它们的索引号调用数组的值。我正在尝试做的是每次 for 循环调用时动态获取影片剪辑的名称。我的代码:
public var allItemsUnlockedTC:Array = new Array("Itemwrench", "Itemsc", "Itemvoltmeter", "Itemgloves", "Itemstirespray");
for(var TCitems:int = 0; TCitems < allItemsUnlockedTC.length; TCitems++)
{
trace("TCitems length: " + TCitems);
trace("Values: " + allItemsUnlockedTC.valueOf([TCitems]));
/*getChildByName(allItemsUnlockedTC.valueOf(TCitems) as MovieClip).x = par.toolCloset.kast_1.slotTC1;//getChildByName("slotTC" + (TCitems + 1)).x + 400;
getChildByName(allItemsUnlockedTC.valueOf(TCitems) as MovieClip).y = par.toolCloset.kast_1.slotTC1;//getChildByName("slotTC" + (TCitems + 1)).y + 245;
getChildByName(allItemsUnlockedTC.valueOf(TCitems) as MovieClip).gotoAndStop(2);
//getChildByName(allItemsUnlockedTC.valueOf(TCitems)).name = ("slotTC" + (TCitems + 1));
NotinventoryParentTC.addChild(getChildByName(allItemsUnlockedTC.valueOf(TCitems) as MovieClip));*/
}
我不是按升序逐个获取值,而是在每次 for 循环调用时一次获取所有值。
如何使用 for 循环按索引调用值?
提前致谢,
米兰
没关系,我解决了。
trace("Values: " + allItemsUnlockedTC[TCitems]);
愚蠢的问题xS