4 Replies Latest reply on Feb 2, 2007 7:59 AM by 72dolphins

    ActionScript SubMenu

    72dolphins Level 1
      Hello-
      I have received a Flash file that contains some ActionScript I cannot decipher. In a nutshell, there is a navigation menu whose content and links are loaded via an XML document. To see the menu in question, view this link: Portfolio

      You can see the menu I am referring to on the left. Essentially, I am trying to add another link below the ones that are currently there. But, whenever I add the new link into the XML file, the Flash movie does not display it. I am at a loss on how to fix this... Could anyone suggest what could be going on?

      For reference, the following is both the XML code and the code that is in the Flash file for loading the XML. Thanks in advance.

      XML:
      <?xml version="1.0"?>

      <menu>
      <item name="identities">
      <sub name="/brand" action="brand.swf">
      </sub>
      <sub name="/event" action="event.swf">
      </sub>
      </item>
      <item name="print ads" action="print_ads.swf">
      </item>
      <item name="collateral" action="collateral.swf">
      </item>
      <item name="direct mail" action="direct_mail.swf">
      </item>
      <item name="web/interactive" action="web.swf"/>
      </item>
      <item name="integrated branding" action="integrated_branding.swf"/>
      </item>
      </menu>

      Actionscript:
      stop();
      var contentFile = "xmlFiles/menuContent.xml";
      var configFile = "xmlFiles/menuConfig.xml";
      contentXML = new XML();
      configXML = new XML();
      contentXML.varTarget = this;
      configXML.ignoreWhite = contentXML.ignoreWhite = true;
      contentXML.onLoad = function (success)
      {
      if (success)
      {
      var vt = this.varTarget;
      var root = this.firstChild;
      vt.menuObj = new Object();
      var i, j, k, m, h, a;

      (i = root.lastChild, j = 1);
      while (i != null)
      {
      vt.menuObj["item" + j] = new Object();
      vt.menuObj["item" + j].name = i.attributes.name;
      vt.menuObj["item" + j].age = i.attributes.age;
      vt.menuObj["item" + j].location = i.attributes.location;
      vt.menuObj["item" + j].action = typeof(i.attributes.action) == "undefined" ? null : i.attributes.action;
      vt.menuObj["item" + j].sub = false;
      if (i.hasChildNodes())
      {
      vt.menuObj["item" + j].sub = true;
      (k = i.lastChild, m = 1);
      while (k != null)
      {
      vt.menuObj["item" + j]["sub" + m] = new Object();
      vt.menuObj["item" + j]["sub" + m].name = k.attributes.name;
      vt.menuObj["item" + j]["sub" + m].age = k.attributes.age;
      vt.menuObj["item" + j]["sub" + m].location = k.attributes.location;
      vt.menuObj["item" + j]["sub" + m].action = typeof(k.attributes.action) == "undefined" ? null : k.attributes.action;
      vt.menuObj["item" + j]["sub" + m].subsub = false;
      if (k.hasChildNodes())
      {
      vt.menuObj["item" + j]["sub" + m].subsub = true;
      (h = k.lastChild, a = 1);
      while (h != null)
      {
      vt.menuObj["item" + j]["sub" + m]["subsub" + a] = new Object();
      vt.menuObj["item" + j]["sub" + m]["subsub" + a].name = h.attributes.name;
      vt.menuObj["item" + j]["sub" + m]["subsub" + a].age = h.attributes.age;
      vt.menuObj["item" + j]["sub" + m]["subsub" + a].location = h.attributes.location;
      vt.menuObj["item" + j]["sub" + m]["subsub" + a].action = h.attributes.action;
      (h = h.previousSibling);
      a++;
      }
      vt.menuObj["item" + j]["sub" + m].Number_SubSubs = a - 1;
      }
      (k = k.previousSibling);
      m++;
      }
      vt.menuObj["item" + j].Number_Subs = m - 1;
      }
      (i = i.previousSibling);
      j++;
      }
      _global.Number_Items = j - 1;
      vt.play();
      }
      else
      {
      trace("ERROR PARSING XML");
      }
      };
      function loadContent()
      {
      contentXML.load(contentFile);
      }
      configXML.onLoad = function (success)
      {
      if (success)
      {
      var root = this.firstChild;
      configObj = new Object();
      configObj.menuSpeed = root.attributes.menuSpeed;
      configObj.menuSpacer = root.attributes.menuSpacer;
      configObj.colorSpeed = root.attributes.colorSpeed;
      allLevels = root.childNodes;
      for(var i=0; i<allLevels.length; i++)
      {
      configObj[allLevels .nodeName] = new Object;
      configObj[allLevels
      .nodeName].overColor = allLevels .attributes.overColor;
      configObj[allLevels
      .nodeName].outColor = allLevels .attributes.outColor;
      configObj[allLevels
      .nodeName].delay = allLevels .attributes.delay;
      }
      loadContent();
      }
      else
      {
      trace("ERROR PARSING XML");
      }
      }
      configXML.load(configFile);
        • 1. Re: ActionScript SubMenu
          SymTsb Level 2
          Please post the XML file showing exactly what you are doing to add another link. It would be helpful.
          • 2. Re: ActionScript SubMenu
            sergiourra Level 1
            What about menuConfig.xml?
            • 3. Re: ActionScript SubMenu
              72dolphins Level 1
              Here are the comtents of the two XML files:

              MenuConfig.xml
              <?xml version="1.0"?>

              <menuConfig menuSpeed="3" menuSpacer="15" colorSpeed="3">

              <item OverColor="0x000000" outColor="0xFF9900" delay="100"/>

              <sub OverColor="0x333333" outColor="0x00CCCC" delay="170"/>

              <subsub OverColor="0x66FF99" outColor="0x66CC99" delay="170"/>

              </menuConfig>

              MenuContent.xml
              <?xml version="1.0"?>

              <menu>
              <item name="identities">
              <sub name="/brand" action="brand.swf">
              </sub>
              <sub name="/event" action="event.swf">
              </sub>
              </item>
              <item name="print ads" action="print_ads.swf">
              </item>
              <item name="collateral" action="collateral.swf">
              </item>
              <item name="direct mail" action="direct_mail.swf">
              </item>
              <item name="web/interactive" action="web.swf"/>
              </item>
              <item name="integrated branding" action="integrated_branding.swf"/>
              </item>
              </menu>
              • 4. Re: ActionScript SubMenu
                72dolphins Level 1
                If anyone is interested, I would be willign to pay them for some consulting help with this.