0 Replies Latest reply on Aug 17, 2009 11:26 AM by garss

    how to create loop for images loaded in movie clip with using childNode from XLM?

    garss

      Hi guys

      i want to create loop for the images that are downloaded to empty movie clip with XML involved.

      I suppose it should be easy, but i am only begginer and can't find a way to say that when the movie clip reaches the final childNode it goes to first one again! I use Flash CS3 and my code is as follows:

       

      function loadXML(loaded) {

      if (loaded) {

      xmlNode = this.firstChild;

      image = [];

      description = [];

      total = xmlNode.childNodes.length;

      for (i=0; i<total; i++) {

      image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;

      }

      firstImage();

      } else {

      content = "loading...";

      }

      }

      xmlData = new XML();

      xmlData.ignoreWhite = true;

      xmlData.onLoad = loadXML;

      xmlData.load("project.xml");

      /////////////////////////////////////

      previous_btn.onRelease = function() {

      prevImage();

      };

      next_btn.onRelease = function() {

      nextImage();

      };

      /////////////////////////////////////

      p = 0;

      this.onEnterFrame = function() {

      filesize = picture.getBytesTotal();

      loaded = picture.getBytesLoaded();

      preloader._visible = true;

      if (loaded != filesize) {

      preloader.preload_bar._xscale = 100*loaded/filesize;

      } else {

      preloader._visible = false;

      if (picture._alpha<100) {

      picture._alpha += 20;

      }

      }

      };

      function nextImage() {

      if (p<(total-1)) {

      p++;

      if (loaded == filesize) {

      picture._alpha = 0;

      picture.loadMovie(image[p], 1);

      }

      }

      }

      function prevImage() {

      if (p>0) {

      p--;

      picture._alpha = 0;

      picture.loadMovie(image[p], 1);

      }

      }

      function firstImage() {

      if (loaded == filesize) {

      picture._alpha = 0;

      picture.loadMovie(image[0], 1);

      }

      }

       

      ------------------------------------------------------------------------------------------ ---------------------------------------------

      and the xml file says:

       

      <?xml version="1.0" encoding="utf-8" standalone="yes"?>

      <images>

       

      <pic>

              <image>image_1.jpg</image>

          </pic>

       

      <pic>

              <image>image_2.jpg</image>

          </pic>

       

      <pic>

              <image>image_3.jpg</image>

          </pic>

       

       

      </images>

       

       

       

      thank you in advance!