0 Replies Latest reply on May 11, 2006 7:36 AM by wyclef

    Help with array increment

    wyclef Level 1
      How can I set

      [code]
      path.forward_btn.onRelease = function() {
      [/code]

      and

      [code]
      path.back_btn.onRelease = function() {
      [/code]

      to only increment iSectionIndex no more than once per folio clip X horizontal slide. I"m having a problem where the array is advancing ahead of itself because you can just keep clicking the buttons. At least I think this is the issue.

      [code]
      var aSectionTxt;
      var iSectionIndex = 0;
      _global.portfolioSection = function(a) {
      targetX = 527;
      path = _root.sectionMC_03.folioClip;
      maxWidth = path.section_mc._width-529;
      velocity = 4;
      aSectionTxt = a.concat();
      path.section_mc.initEnterFrame();
      path.forward_btn.onRelease = function() {
      if (targetX>-(maxWidth-370)) {
      targetX -= 370;
      //
      var dir = 1;
      if (iSectionIndex+dir>=0 && iSectionIndex+dir<=aSectionTxt.length) {
      iSectionIndex += dir;
      }
      // iSectionIndex must be set here -- not at the end of the enterframe func.
      path.section_mc.initEnterFrame();
      }
      };
      path.back_btn.onRelease = function() {
      if (targetX<527) {
      targetX += 370;
      //
      var dir = -1;
      if (iSectionIndex+dir>=0 && iSectionIndex+dir<=aSectionTxt.length) {
      iSectionIndex += dir;
      }
      // iSectionIndex must be set here -- not at the end of the enterframe func.
      path.section_mc.initEnterFrame();
      }
      };
      };
      MovieClip.prototype.initEnterFrame = function() {
      path.section_txt.text = "";
      if (mcMovieToRemove != null) {
      removeMovieClip(mcMovieToRemove);
      }
      this.onEnterFrame = function() {
      //trace("Running Enter Frame");
      this._x += (targetX-this._x)/velocity;
      if (this._x<(targetX+1) && this._x>(targetX-1)) {
      //trace("Stopping Enter Frame");
      this._x = targetX;
      setSectionText();
      delete this.onEnterFrame;
      }
      };
      };
      _global.setSectionText = function() {
      if (typeof (aSectionTxt[iSectionIndex]) == "string") {
      path.section_txt.text = aSectionTxt[iSectionIndex];
      } else {
      mcMovieToRemove = path.attachMovie(aSectionTxt[iSectionIndex].linkage, "mcSectionMovie", 10);
      mcMovieToRemove._x = aSectionTxt[iSectionIndex].x;
      mcMovieToRemove._y = aSectionTxt[iSectionIndex].y;
      }
      };
      [/code]