Skip navigation
Currently Being Moderated

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

Aug 1, 2012 1:13 PM

Hi,

 

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,

 

~Chipleh

 

 

for each (var module:Object in courseData[0].modules)
{                                                
    var mcMenuItem:mcMenu=new mcMenu();                            
    menuHolder.addChild(mcMenuItem);                                        
    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();                            
            menuHolder.addChild(mcLessonItem);                                        
            mcLessonItem.x = mcMenuItem.x + 25;// + mcMenuItem.width;
            mcLessonItem.y = (?);
            mcLessonItem.name = "mcLessonMenuItem" + j;
        }
    }
}

 

 

 

 

description.jpg

 
Replies
  • Currently Being Moderated
    Aug 1, 2012 1:27 PM   in reply to Chipleh

    You'll need to have a yValue variable that you increment as you add each new menu item.  The increment value will be the height property of the item last planted.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points