• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Engaged ,
Aug 01, 2012 Aug 01, 2012

Copy link to clipboard

Copied

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

TOPICS
ActionScript

Views

440

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 01, 2012 Aug 01, 2012

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines