1 Reply Latest reply: Aug 1, 2012 1:27 PM by Ned Murphy RSS

    construct dynamic menu through iteration of [for each]...

    Chipleh Community Member



      I'm trying to create a menu based off a json file structure. Per the code below, I'm trying to build a menu structure that resembles the image below. In order to complete this piece of code, I'm trying to figure out what [mcMenuItem.y] and [mcLessonItem.y] would be. I know this is a seemingly simple problem, but I haven't done something such as this in some time and it's slipped my mind on how to construct the y value through iteration. Any help would be very appreciated,





      for each (var module:Object in courseData[0].modules)
          var mcMenuItem:mcMenu=new mcMenu();                            
          mcMenuItem.name = "mcMenuItem" + i;
          mcMenuItem.y = mcMenuItem.y + (mcMenuItem.height * i);
          for each (var moduleNumber:Object in module)
              j = 0;
              for each (var lessons:Object in moduleNumber)
                  var mcLessonItem:mcMenu=new mcMenu();                            
                  mcLessonItem.x = mcMenuItem.x + 25;// + mcMenuItem.width;
                  mcLessonItem.y = (?);
                  mcLessonItem.name = "mcLessonMenuItem" + j;