1 Reply Latest reply on Jul 13, 2007 5:23 AM by wackydesigner

    Adding Pause and Replay Buttons

    wackydesigner Level 1
      Ok here is my script for an external XML loading Flash Gallery...
      1. How do I add a "constant" Pause and Replay on this?
      2. Every time I add something to the stage the "fade effect" affects that too!

      Thanks in advance.

      ------------------------------------------------------------------------------------------ --------------------
      delay = 5000;
      //////////////////////////////////////
      function loadXML(loaded) {
      if (loaded) {
      xmlNode = this.firstChild;
      image = [];
      description = [];
      total = xmlNode.childNodes.length;
      for (i=0; i<total; i++) {
      image = xmlNode.childNodes.childNodes[0].firstChild.nodeValue;
      description = xmlNode.childNodes.childNodes[1].firstChild.nodeValue;
      }
      id = setInterval(preloadPic, 100);
      } else {
      content = "file not loaded!";
      }
      }
      xmlData = new XML();
      xmlData.ignoreWhite = true;
      xmlData.onLoad = loadXML;
      xmlData.load("images.xml");
      // ///////////////////////////////////
      var loadTot = 0;
      var k = 0;
      function preloadPic() {
      clearInterval(id);
      var con = picture.duplicateMovieClip("con"+k, 9984+k);
      con.loadMovie(image[k]);
      var temp = _root.createEmptyMovieClip("temp"+k, 99+k);
      temp.onEnterFrame = function() {
      var total = con.getBytesTotal();
      var loaded = con.getBytesLoaded();
      percent = Math.round((loaded/total*100)/image.length);
      preloader.preload_bar._xscale = loadTot+percent;
      info.text = "Loading picture "+k+" of "+image.length+" total";
      if (loaded == total && total>4) {
      con._visible = 0;
      nextPic();
      loadTot += percent;
      delete this.onEnterFrame;
      }
      }
      }
      function nextPic() {
      if (k<image.length-1) {
      k++;
      preloadPic();
      }
      else {
      firstImage();
      preloader._visible = 0;
      info.text = "";
      }
      }
      listen = new Object();
      listen.onKeyDown = function() {
      if (Key.getCode() == Key.LEFT) {
      prevImage();
      } else if (Key.getCode() == Key.RIGHT) {
      nextImage();
      }
      }
      Key.addListener(listen);
      previous_btn.onRelease = function() {
      prevImage();
      };
      next_btn.onRelease = function() {
      nextImage();
      }
      // ///////////////////////////////////
      var p = 0;
      var current;
      MovieClip.prototype.fadeIn = function() {
      if (this._alpha<100) {
      current._alpha -= 5;
      this._alpha += 5;
      } else {
      current._visible = 0;
      delete this.onEnterFrame;
      }
      };
      function nextImage() {
      if(p<(total-1)){
      current = this["con"+p];
      p++;
      var picture = this["con"+p];
      picture._visible = 1;
      picture._alpha = 0;
      picture.onEnterFrame = fadeIn;
      desc_txt.text = description[p];
      picture_num();
      slideshow();
      }
      if (isPaused == true) {
      current = this["con"+p];
      p<total-1 ? p++ : p=0;
      preloadPic();
      }
      }
      function prevImage() {
      if (p>0){
      current = this["con"+p];
      p--;
      var picture = this["con"+p];
      picture._visible = 1;
      picture._alpha = 0;
      picture.onEnterFrame = fadeIn;
      desc_txt.text = description[p];
      picture_num();
      }
      }
      function firstImage() {
      con0._visible = 1;
      con0._alpha = 0;
      con0.onEnterFrame = fadeIn;
      desc_txt.text = description[0];
      picture_num();
      slideshow();
      }
      function picture_num() {
      current_pos = p+1;
      pos_txt.text = current_pos+" / "+total;
      }
      function slideshow() {
      myInterval = setInterval(pause_slideshow, delay);
      function pause_slideshow() {
      clearInterval(myInterval);
      if (p == (total-1)) {
      //Resetting...fadeout=300 milliseconds.
      endFadeOut = setInterval(fadeOut, 300);
      //Try using a movie clip called restart_mc that is a button
      _root.attachMovie("restart_mc");
      } else {
      nextImage();
      }
      }
      }
      ------------------------------------------------------------------------------------------ -
      Here is the Source Files:
      Download the Sources