0 Replies Latest reply on Jun 17, 2006 12:43 AM by kanukukreja

    XML +loadMovie

    kanukukreja
      I'm trying to create a menu through XML and i'm using 2 attributes in dat XML one is buttons name and another is link.
      This link is not a URL this is a name of another swf which i wanna load.

      stop();
      xmlData = new XML();
      xmlData.ignoreWhite = true;
      xmlData.onLoad = loadXML;
      var btn_arr = new Array();
      var link_arr = new Array();
      function loadXML(loaded) {
      if (loaded) {
      xmlNode = this.firstChild;
      total = xmlNode.childNodes.length;
      xml_arr = xmlNode.childNodes;
      for (i=0; i<total; i++) {
      btn_arr.push(xml_arr .attributes.heading);
      link_arr.push(xml_arr
      .attributes.pageToLoad);
      trace('"'+link_arr +'"');
      }
      }
      makeButtons();
      }
      function makeButtons() {
      for (var i = 0; i<xml_arr.length; i++) {
      button0_mc._visible = false;
      var btn = button0_mc.duplicateMovieClip("btn"+i+"_mc", 1000+i);
      btn._y = this["btn"+(i-1)+"_mc"]._y+this["btn"+(i-1)+"_mc"]._height+5;
      btn._x = 1.1;
      btn.button_txt.text = btn_arr
      ;
      btn.onRollOver = function() {
      trace(bt._name) //always come to btn4_mc
      this.effectIn("in");
      };
      btn.onRollOut = function() {
      this.effectIn("out");
      };
      btn.onRelease = function() {
      loadMovieNum('"'+link_arr +'"', i+10); //showing error loading URL
      };
      }
      }
      xmlData.load("xml/menu.xml");

      //////////////////////////////////// XML ///////////////////////

      <nav>
      <nav_item heading="Home" pageToLoad="site.swf" />
      <nav_item heading="About Flash" pageToLoad="flash.swf" />
      <nav_item heading="Flash Resources" pageToLoad="resources.swf" />
      <nav_item heading="Flash Forums" pageToLoad="forums.swf" />
      <nav_item heading="Contact Us" pageToLoad="contact_us.swf" />
      </nav>