3 Replies Latest reply on Dec 16, 2011 5:11 AM by kglad

    XML Current & Next Item

    dz-00

      Hi, I have this code within the flash to load in the XML file. A list of buttons is generated from the XML list. How do I find out which is the current 'item' selected, and then how to select the next 'item' from the XML list - Thanks

       


      myXML = new XML();
      myXML.ignoreWhite = true;
      myXML.load("items.xml");
      myXML.onLoad = function(_status) {
      if (_status) {
      var clientList:Array = [];
      var clientRegistry:Object = {};
      tempxml = myXML.firstChild.childNodes;
      var space = 10;

       

      for (var i = 0; i<tempxml.length; i++) {
      var clientData:Object = {};
      var item = all_items.list_mc.attachMovie("clip", "clip"+i, i);

       

      item._x = clientData["x"]=(item._width+space)*i;
      item.title_txt.text = clientData["title"]=tempxml[i].attributes.title;
      item.path = tempxml[i].attributes.path;
      item.thumb = tempxml[i].attributes.thumb;
      item.swf = tempxml[i].attributes.swf;
      }

       

      }
      };

        • 1. Re: XML Current & Next Item
          kglad Adobe Community Professional & MVP

          use:

           

           


          myXML = new XML();
          myXML.ignoreWhite = true;
          myXML.load("items.xml");
          myXML.onLoad = function(_status) {
          if (_status) {
          var clientList:Array = [];
          var clientRegistry:Object = {};
          tempxml = myXML.firstChild.childNodes;
          var space = 10;

           

          for (var i = 0; i<tempxml.length; i++) {
          var clientData:Object = {};
          var item = all_items.list_mc.attachMovie("clip", "clip"+i, i);

          item.ivar=i;

          item.onRelease=function(){

          trace("item "+this.ivar+" was clicked\nNext item is "+(this.ivar+1)+" unless "+this.ivar+" = "+(tempxml.length-1));

          }

          item._x = clientData["x"]=(item._width+space)*i;
          item.title_txt.text = clientData["title"]=tempxml[i].attributes.title;
          item.path = tempxml[i].attributes.path;
          item.thumb = tempxml[i].attributes.thumb;
          item.swf = tempxml[i].attributes.swf;
          }

           

          }
          };

          • 2. Re: XML Current & Next Item
            dz-00 Level 1

            Thanks Kglad

             

            When the user clicks an 'item' it loads in item attributes into an mc as shown above. How would I load the next items attributes, as in the following item in the XML list?

            • 3. Re: XML Current & Next Item
              kglad Adobe Community Professional & MVP

              the only code showing an item mouse handler is the code i suggested and that code is not loading anything.

              1 person found this helpful