2 Replies Latest reply on Jan 27, 2007 8:24 AM by jacobonline

    setInterval and XML Load Problem

    jacobonline Level 1
      Hello,
      I 'm having the simple problem of making sure the XML is loaded before beginning the Interval sequence. Therefore it is missing some of the XML data when loading. See example:
      http://alt.coxnewsweb.com/statesman/img/advertising/_jacob/Site1/products.html

      I tried a success boolean with the XML onLoad Handler, but my setInterval stopped working. I could easily just not know how to properly implement XML onLoad.

      Can someone help me out with properly loading the XML document before the setInterval is initiated.
      Thank You - Jacob

      Here is the Working Code of the example given...

      //New XML Object
      var mydata:XML = new XML();
      //ignores formatting of XML files tabs, returns, ect.
      mydata.ignoreWhite = true;
      //Setup onLoad Function
      mydata.onLoad = loadXML;
      //Loads actual XML Data File
      mydata.load("data.xml");

      //setInerval Vars
      var intervalId:Number;
      var count:Number = 1;
      var maxCount:Number = 20;
      var duration:Number = 100;

      //Thumbnail Position Vars
      var originalx:Number = 20;
      var originaly:Number = 55;
      currentx = originalx;
      currenty = originaly;

      var i:Number = 0;

      //Create Thumbnails Interval
      function thumbInterval():Void {
      //trace(i);
      //Controls # of Thumbnails per line
      if ((i % 5 == 0) && (i > 0)) {
      currenty += 125;
      currentx=originalx;
      }
      //Attatch Library MC
      _root.attachMovie("thumbnailMC", "thumbnailMC" + i, 1000 + i);
      //Load Image, text, and position
      _root["thumbnailMC" + i].thumbnailname = mydata.firstChild.childNodes .childNodes[0].firstChild.nodeValue;
      _root["thumbnailMC" + i].textbox.productdescr = mydata.firstChild.childNodes
      .childNodes[1].firstChild.nodeValue;
      _root["thumbnailMC" + i]._x = currentx;
      _root["thumbnailMC" + i]._y = currenty;
      currentx += 130;
      i++
      if(count >= maxCount) {
      clearInterval(intervalId);
      }
      count++;
      }
      intervalId = setInterval(this, "thumbInterval", duration);