0 Replies Latest reply on Dec 7, 2006 12:38 PM by BazaarMan

    dynamically assigning variable in xml loop

      I am trying to dynamically assign a variable name so I can build an accordian nav from and XML doc. the code looks like this:

      ACnav['depthChild0']._alpha = 0;
      ACnav.setStyle("color", 0x0ffffff);

      ACnav.setStyle ("openEasing", mx.transitions.easing.strong.easeout);
      ACnav.setStyle ("selectionDuration", mx.transitions.duration.slow);

      navXML = new XML();
      navXML.ignoreWhite = true;
      var currentSection = 0;

      function buildNav () {
      DisposableXML = new XML();
      TempXML = new XML();
      button = new Array();
      //buttonNum = new Array();
      subitem = new Array();
      menuItem = new Array();
      o = new Array ();
      subitemlocation = new Array();
      DisposableList = new Array();
      buttonList = navXML.firstChild.childNodes;
      i = 0;
      sectionLength = buttonList.length;
      while (i<=buttonList.length) {
      if (buttonList .nodeName.toLowerCase() == "button") {
      DisposableXML = buttonList
      DisposableList = DisposableXML.childNodes;
      buttonName = buttonList .attributes.name;
      set ("buttonNum", "buttonNumber"+i);

      ii = 0;
      //ACnav.createChild("View", buttonNum, {label: buttonName, icon: "mainNav"});
      = ACnav.createChild("View", buttonNum, {label: buttonName, icon: "mainNav"});
      while (ii<=DisposableList.length) {
      TempXML = DisposableList[ii];
      if (DisposableList[ii].nodeName.toLowerCase() == "subitem") {
      subitem = TempXML.attributes.name;
      //subitemlocation = TempXML.attributes.location;
      subitemNum="subitemNum"+[ii]+ ;
      = ACnav.buttonNum.createChild("subNav", subitemNum, {childText: subitem});
      menuItem .move(0, oY);
      ii = Number(ii)+1;

      i = Number(i)+1;

      The problem lies with this line: button
      = ACnav.createChild("View", buttonNum, {label: buttonName, icon: "mainNav"});

      If I quote the "buttonNum", it works, but jumbles the subnav items together vs in the proper node. I need to have that declared dynamically so that each parent node has a differentID and then createchild goes under that. Anyway, I've tried alot of stuff over the last few days and its getting frustrating.

      Thanks for the help if anyone contributes!