0 Replies Latest reply on May 5, 2006 11:05 PM by blacey777

    need button state to correspond w/ images

    blacey777
      Hi,
      I'm new to actionscript (2) and would be eternally grateful for some help. I'm creating a portfolio which has tiny square buttons (one for each image) and arrows buttons to navigate through the portfolio. Everything is working just great, but I need the square buttons, when pushed, to change alpha or turn to dk grey instead of lt grey, and remain this way until the next image is shown. They should act as indicators as to where you are in the portfolio. The code I'm using is as follows:

      picture._x=24;
      picture._y=31;
      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;
      }
      firstImage();
      } else {
      content = "file not loaded!";
      }
      }
      xmlData = new XML();
      xmlData.ignoreWhite = true;
      xmlData.onLoad = loadXML;
      xmlData.load("images5.xml");
      /////////////////////////////////////

      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 += 10;
      }
      }
      };
      function nextImage() {
      if (p<(total-1)) {
      p++;
      if (loaded == filesize) {
      picture._alpha = 0;
      picture.loadMovie(image[p], 1);
      desc_txt.text = description[p];
      picture_num();
      }
      }
      }
      function prevImage() {
      if (p>0) {
      p--;
      picture._alpha = 0;
      picture.loadMovie(image[p], 1);
      desc_txt.text = description[p];
      picture_num();
      }
      }
      function firstImage() {
      if (loaded == filesize) {
      picture._alpha = 0;
      picture.loadMovie(image[0], 1);
      desc_txt.text = description[0];
      picture_num();
      }
      }
      function picture_num() {
      current_pos = p+1;
      pos_txt.text = current_pos+" / "+total;
      }
      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();
      };
      button1.onPress = function() {
      if (p=0) {
      if (loaded == filesize) {
      picture._alpha = 0;
      picture.loadMovie(image[0], 1);
      desc_txt.text = description[0];
      picture_num();
      }
      }
      };
      button2.onPress = function() {
      if (p=1) {
      if (loaded == filesize) {
      picture._alpha = 0;
      picture.loadMovie(image[1], 1);
      desc_txt.text = description[1];
      picture_num();
      }
      }
      };
      button3.onPress = function() {
      if (p=2) {
      if (loaded == filesize) {
      picture._alpha = 0;
      picture.loadMovie(image[2], 1);
      desc_txt.text = description[2];
      picture_num();
      }
      }
      };
      button4.onPress = function() {
      if (p=3) {
      if (loaded == filesize) {
      picture._alpha = 0;
      picture.loadMovie(image[3], 1);
      desc_txt.text = description[3];
      picture_num();
      }
      }
      };
      button5.onPress = function() {
      if (p=4) {
      if (loaded == filesize) {
      picture._alpha = 0;
      picture.loadMovie(image[4], 1);
      desc_txt.text = description[4];
      picture_num();
      }
      }
      }
      button6.onPress = function() {
      if (p=5) {
      if (loaded == filesize) {
      picture._alpha = 0;
      picture.loadMovie(image[5], 1);
      desc_txt.text = description[5];
      picture_num();
      }
      }
      }


      Please let me know if anyone has any suggestions for how to go about finishing this script.

      P.S. the arrow buttons should also activate which square button changes state.
      Thanks so much!!!