Apache flex Flex 3:使用数组项值作为对象名称

Apache flex Flex 3:使用数组项值作为对象名称,apache-flex,Apache Flex,如果数组中有一个表示模块名称的项目列表: var phaseNames:Array = new Array("directorsPrep", "checkIO", "pickupPhoto", "pickupPhoto", "syncing", "dailies", "pictureEdit", "soundEdit", "soundMix", "colorCorrection", "finishing"); 我想逐一介绍这些,并在每个模块的每个实例中调用一个函数,我该怎么做呢。到目前为止,我

如果数组中有一个表示模块名称的项目列表:

var phaseNames:Array = new Array("directorsPrep", "checkIO", "pickupPhoto", "pickupPhoto", "syncing", "dailies", "pictureEdit", "soundEdit", "soundMix", "colorCorrection", "finishing");
我想逐一介绍这些,并在每个模块的每个实例中调用一个函数,我该怎么做呢。到目前为止,我有以下几点:

private function changeStartViewDate(numDays:Number):void
{
    startViewDate = rightDate(startViewDate.getMonth(), startViewDate.getDate() + numDays, startViewDate.getFullYear());
    getDateInfo();
    determineCalendarWeek();
    var phaseNames:Array = new Array("directorsPrep", "checkIO", "pickupPhoto", "pickupPhoto", "syncing", "dailies", "pictureEdit", "soundEdit", "soundMix", "colorCorrection", "finishing");

    for (var i:int = 0; i < wholeProject.length; i++)
    {
        wholeProject[i].moveProject(Number((1-2) * numDays));
    }
    for (i = 0; i < phaseNames.length; i++)
    {
        for (var j:int = 0; j < [phaseNames[i]].length; j++)
        {
            [phaseNames[i]].movePhase(Number((-1) * numDays));
        }
    }
}
我试着做了如下的事情,但没有成功:

[phaseNames[i].movePhase(Number((-1) * numDays))];
上面试图弄明白这一点的尝试给了我以下错误

1064:无效元数据


任何帮助都将不胜感激。

我假设:

  • phaseNames数组的每个值都引用某个其他类的实际实例[而不是该类的名称]
  • phaseNames数组中定义的实例是当前类的子类
  • 您应该能够执行以下操作:

    var childName = phaseNames[0];
    var myChild : myObjectType = this[childName];
    // then call function
    myChild.doStuff();
    
    这种方法与你所拥有的并没有什么不同;我只是多排几行。我还添加了this关键字来访问这个孩子

    我敢打赌,如果你直接尝试,它会起作用:

    this[phaseNames[i]].movePhase(Number((-1) * numDays));
    
    我想知道为什么你没有创建一个包含所有实例的数组,而不是一个包含所有指向实例的变量名的数组

    this[phaseNames[i]].movePhase(Number((-1) * numDays));