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; } } }
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.