Flex 3:使用变量值来帮助定义另一个变量......需要一些帮助。

时间:2011-07-28 16:00:39

标签: xml flex

我希望我能够解释得这么好......

我创建了一个包含几种不同类型阶段的xml文档:directorprep,checkInOut,project,pickupPhoto,syncing和daily。一旦我的httpService加载了xml,结果函数如下:

private function processPhases(e:ResultEvent):void
{
    var phases:Array = new Array("directorsprep", "checkInOut", "project", "pickupPhoto", "syncing", "daily");
    var xmlList:XMLList = new XMLList;
    var dupString:String = "|";
    var tempArray:Array = new Array;
    var tempString:String = new String;

    for (var i:int = 0; i < phases.length; i++)
    {
        xmlList = XML(e.result).phases[i];
        dupString = "|";
        tempArray = new Array;

        for (var j:int = 0; j < xmlList.length(); j++)
        {
            if (phases[i] == "directorsPrep")
                tempString = "|" + xmlList[j].prepDBID + "|";
            else if (phases[i] == "checkInOut")
                tempString = xmlList[j].checkDBID;
            else if (phases[i] == "project")
                tempString = xmlList[j].dbID;
            else if (phases[i] == "pickupPhoto")
                tempString = xmlList[j].pickupPhotoDBID;
            else if (phases[i] == "syncing")
                tempString = xmlList[j].syncDBID;
            else if (phases[i] == "daily")
                tempString = xmlList[j].dailyDBID;

            if (dupString.indexOf(tempString) == -1)
            {
                tempArray = new Array;
                if (phases[i] == "directorsPrep")
                {
                    tempArray[0] = xmlList[j].prepDBID;
                    tempArray[1] = xmlList[j].projectDBID;
                    tempArray[2] = xmlList[j].startDate;
                    tempArray[3] = xmlList[j].numdays;
                    tempArray[4] = xmlList[j].positions;
                    directorsPrepAC.addItem(tempArray);             
                    dupString += "|" + xmlList[j].prepDBID + "|";
                }
                else if (phases[i] == "checkInOut")
                {
                    tempArray[0] = xmlList[j].checkDBID;
                    tempArray[1] = xmlList[j].projectDBID;
                    tempArray[2] = xmlList[j].startdate;
                    tempArray[3] = xmlList[j].numdays;
                    tempArray[4] = xmlList[j].positions;
                    checkInOutAC.addItem(tempArray);                
                    dupString += "|" + xmlList[j].checkDBID + "|";
                }
                else if (phases[i] == "project")
                {
                    tempArray[0] = xmlList[j].dbID;
                    tempArray[1] = xmlList[j].workingTitle;
                    tempArray[2] = xmlList[j].projName;
                    tempArray[3] = xmlList[j].startDate;
                    tempArray[4] = xmlList[j].positions;
                    projectsAC.addItem(tempArray);              
                    dupString += "|" + xmlList[j].dbID + "|";
                }
                else if (phases[i] == "pickupPhoto")
                {
                    tempArray[0] = xmlList[j].pickupPhotoDBID;
                    tempArray[1] = xmlList[j].projectDBID;
                    tempArray[2] = xmlList[j].startDate;
                    tempArray[3] = xmlList[j].numdays;
                    tempArray[4] = xmlList[j].positions;
                    pickupPhotoAC.addItem(tempArray);               
                    dupString += "|" + xmlList[j].pickupPhotoDBID + "|";
                }
                else if (phases[i] == "syncing")
                {
                    tempArray[0] = xmlList[j].syncDBID;
                    tempArray[1] = xmlList[j].projectDBID;
                    tempArray[2] = xmlList[j].startDate;
                    tempArray[3] = xmlList[j].numdays;
                    tempArray[4] = xmlList[j].positions;
                    syncingAC.addItem(tempArray);               
                    dupString += "|" + xmlList[j].syncDBID + "|";
                }
                else if (phases[i] == "daily")
                {
                    tempArray[0] = xmlList[j].dailyDBID;
                    tempArray[1] = xmlList[j].projectDBID;
                    tempArray[2] = xmlList[j].startDate;
                    tempArray[3] = xmlList[j].numdays;
                    tempArray[4] = xmlList[j].positions;
                    dailiesAC.addItem(tempArray);               
                    dupString += "|" + xmlList[j].dailyDBID + "|";
                }
            }
        }
    }
}

给我带来麻烦的部分,以及这篇文章的原因是:

xmlList = XML(e.result).phases[i];

如果这不是表示要查看哪个不同阶段的正确方法,有人可以告诉我它是什么吗?

谢谢你的时间, BRDS

1 个答案:

答案 0 :(得分:1)

尝试改为使用:

xmlList = XML(e.result)[phases[i]];