2 Replies Latest reply on Jan 5, 2007 2:41 AM by arunbe

    preloading images from xml file for ready display

    kakas
      Hi ,

      I have a xml file from which i am loading images to view. every time the suer needs to clik on the images to load it from the xml file . Is it possible to preload the images..so if th euser clicks on the thumbnail the image will load fast?

      this is the code written:

      delay = 3000;
      //-----------------------
      function loadXML(loaded) {
      if (loaded) {
      xmlNode = this.firstChild;
      image = [];
      th = [];
      total = xmlNode.childNodes.length;
      for (i=0; i<total; i++) {
      image = xmlNode.childNodes.childNodes[0].firstChild.nodeValue;
      th = xmlNode.childNodes.childNodes[1].firstChild.nodeValue;
      }
      firstImage();
      } else {
      content = "file not loaded!";
      }
      }
      xmlData = new XML();
      xmlData.ignoreWhite = true;
      xmlData.onLoad = loadXML;
      xmlData.load("images.xml");
      p = 0;
      loadline._alpha = 0;
      this.onEnterFrame = function() {
      filesize = picture.getBytesTotal();
      loaded = picture.getBytesLoaded();
      preloader._visible = true;
      if (loaded != filesize) {
      loadline._alpha = 100*loaded/filesize;
      preloader.preload_bar._xscale = 100*loaded/filesize;
      } else {
      preloader._visible = false;
      if (picture._alpha<100) {
      picture._alpha += 10;
      }
      if (pictureth._alpha<100) {
      pictureth._alpha += 10;
      }
      }
      };
      function firstImage() {
      if (loaded == filesize) {
      picture._alpha = 0;
      picture.loadMovie(image[0], 1);
      pictureth._alpha = 0;
      pictureth.loadMovie(th[0], 1);
      picture_num();
      slideshow();
      }
      }
      function picture_num() {
      current_pos = p;
      pos_txt.text = current_pos+" / "+total;
      }
      function slideshow() {
      myInterval = setInterval(pause_slideshow, delay);
      function pause_slideshow() {
      clearInterval(myInterval);
      if (p == (total-1)) {
      p = 0;
      firstImage();
      } else {
      nextImage();
      }
      }
      }
      slideshow();
      //---------
      -------------------------------------------------******************----------------------- ----thx is xml

      <?xml version="1.0" encoding="utf-8" standalone="yes"?>
      <images>
      <pic>
      <image>img01.jpg</image>
      <caption>img01th.jpg</caption>
      </pic>
      <pic>
      <image>img02.jpg</image>
      <caption>img02th.jpg</caption>
      </pic>
      <pic>
      <image>img03.jpg</image>
      <caption>img03th.jpg</caption>
      </pic>
      <pic>
      <image>img04.jpg</image>
      <caption>img04th.jpg</caption>
      </pic>
      <pic>
      <image>img05.jpg</image>
      <caption>img05th.jpg</caption>
      </pic>
      <pic>
      <image>img06.jpg</image>
      <caption>img06th.jpg</caption>
      </pic>
      <pic>
      <image>img07.jpg</image>
      <caption>img07th.jpg</caption>
      </pic>
      <pic>
      <image>img08.jpg</image>
      <caption>img08th.jpg</caption>
      </pic>
      <pic>
      <image>img09.jpg</image>
      <caption>img09th.jpg</caption>
      </pic>
      <pic>
      <image>img10.jpg</image>
      <caption>img10th.jpg</caption>
      </pic>
      <pic>
      <image>img11.jpg</image>
      <caption>img11th.jpg</caption>
      </pic>
      <pic>
      <image>img12.jpg</image>
      <caption>img12th.jpg</caption>
      </pic>
      <pic>
      <image>img13.jpg</image>
      <caption>img13th.jpg</caption>
      </pic>
      <pic>
      <image>img14.jpg</image>
      <caption>img14th.jpg</caption>
      </pic>
      <pic>
      <image>img15.jpg</image>
      <caption>img15th.jpg</caption>
      </pic>
      <pic>
      <image>img16.jpg</image>
      <caption>img16th.jpg</caption>
      </pic>
      <pic>
      <image>img17.jpg</image>
      <caption>img17th.jpg</caption>
      </pic>
      <pic>
      <image>img18.jpg</image>
      <caption>img18th.jpg</caption>
      </pic>
      <pic>
      <image>img19.jpg</image>
      <caption>img19th.jpg</caption>
      </pic>
      <pic>
      <image>img20.jpg</image>
      <caption>img20th.jpg</caption>
      </pic>
      <pic>
      <image>img21.jpg</image>
      <caption>img21th.jpg</caption>
      </pic>
      <pic>
      <image>img22.jpg</image>
      <caption>img22th.jpg</caption>
      </pic>
      <pic>
      <image>img23.jpg</image>
      <caption>img23th.jpg</caption>
      </pic>
      <pic>
      <image>img24.jpg</image>
      <caption>img24th.jpg</caption>
      </pic>
      <pic>
      <image>img25.jpg</image>
      <caption>img25th.jpg</caption>
      </pic>
      <pic>
      <image>img26.jpg</image>
      <caption>img26th.jpg</caption>
      </pic>
      <pic>
      <image>img27.jpg</image>
      <caption>img27th.jpg</caption>
      </pic>
      <pic>
      <image>img28.jpg</image>
      <caption>img28th.jpg</caption>
      </pic>
      <pic>
      <image>img29.jpg</image>
      <caption>img29th.jpg</caption>
      </pic>
      <pic>
      <image>img30.jpg</image>
      <caption>img30th.jpg</caption>
      </pic>
      <pic>
      <image>img31.jpg</image>
      <caption>img31th.jpg</caption>
      </pic>
      <pic>
      <image>img32.jpg</image>
      <caption>img32th.jpg</caption>
      </pic>
      <pic>
      <image>img33.jpg</image>
      <caption>img33th.jpg</caption>
      </pic>
      <pic>
      <image>img34.jpg</image>
      <caption>img34th.jpg</caption>
      </pic>
      <pic>
      <image>img35.jpg</image>
      <caption>img35th.jpg</caption>
      </pic>
      <pic>
      <image>img36.jpg</image>
      <caption>img36th.jpg</caption>
      </pic>
      <pic>
      <image>img37.jpg</image>
      <caption>img37th.jpg</caption>
      </pic>
      <pic>
      <image>img38.jpg</image>
      <caption>img38th.jpg</caption>
      </pic>
      <pic>
      <image>img39.jpg</image>
      <caption>img39th.jpg</caption>
      </pic>
      <pic>
      <image>img40.jpg</image>
      <caption>img40th.jpg</caption>
      </pic>
      <pic>
      <image>img41.jpg</image>
      <caption>img41th.jpg</caption>
      </pic>
      <pic>
      <image>img42.jpg</image>
      <caption>img42th.jpg</caption>
      </pic>
      <pic>
      <image>img43.jpg</image>
      <caption>img43th.jpg</caption>
      </pic>
      <pic>
      <image>img44.jpg</image>
      <caption>img44th.jpg</caption>
      </pic>
      <pic>
      <image>img45.jpg</image>
      <caption>img45th.jpg</caption>
      </pic>
      </images>