3 Replies Latest reply on Aug 13, 2009 8:12 AM by kglad

    Tween class thumbnail scrolling - trouble with button control

    giorgio789

      Hi all, I'm a newbie, totally stuck, and would GREATLY appreciate any help on this. All I've been trying to do is to move a string of thumbnails - thumbHolder_mc - incrementally (like every 386 pixels) left and right, controling it with arrow buttons. Code below works like a charm EXCEPT when I try to stop the tween motion on either end.

      I tried everything - _visible = false, enabled = false, delete function, etc etc, nothing works. In the my script below, buttons get disabled, but never recover. Function never comes "back to life", which is what I thought it was supposed to do:


      stop();
      //connect right and left arrow buttons to function:
      abuttonright.onRelease = function() {
      tweenRight();
      }
      abuttonleft.onRelease = function() {
      tweenLeft();
      }

      //create incremental movement forward:
      function tweenRight() {
      easeType = mx.transitions.easing.Strong.easeOut;
      var begin = thumbHolder_mc._x;
      var end = thumbHolder_mc._x -=386;
      var time = 1;
      var mc = thumbHolder_mc;
      Tween = new mx.transitions.Tween(mc, "_x", easeType, begin, end, time, true);

      //disable and dim button once the thumbnail reaches the end:
      if (thumbHolder_mc._x < 140) {
      delete abuttonright.onRelease;
      abuttonright._alpha = 30;
      }else{
      abuttonright._alpha = 100;
      }
      }

      //create incremental movement backward:
      function tweenLeft() {
      easeType = mx.transitions.easing.Strong.easeOut;
      var begin = thumbHolder_mc._x;
      var end = thumbHolder_mc._x +=386;
      var time = 1;
      var mc = thumbHolder_mc;
      Tween = new mx.transitions.Tween(mc, "_x", easeType, begin, end, time, true);

      //disable and dim button once the thumbnail reaches the beginning:
      if (thumbHolder_mc._x > 140) {
      delete abuttonleft.onRelease;
      abuttonleft._alpha = 30;
      }else{
      abuttonleft._alpha = 100;
      }
      }

      Would totally appreciate anyone's ideas out of this snag!

        • 1. Re: Tween class thumbnail scrolling - trouble with button control
          kglad Adobe Community Professional & MVP

          depending on the location of thumbHolder_mc's reg point, use something like:

           


          stop();
          //connect right and left arrow buttons to function:
          abuttonright.onRelease = function() {
          tweenRight();
          }
          abuttonleft.onRelease = function() {
          tweenLeft();
          }

          //create incremental movement forward:
          function tweenRight() {
          easeType = mx.transitions.easing.Strong.easeOut;
          var begin = thumbHolder_mc._x;
          var end = Math.max(thumbHolder_mc._x-386,Stage.width-thumbHolder_mc._width);  // if reg point on left
          var time = 1;
          var mc = thumbHolder_mc;
          Tween = new mx.transitions.Tween(mc, "_x", easeType, begin, end, time, true);

          //disable and dim button once the thumbnail reaches the end:
          if (thumbHolder_mc._x < 140) {
          delete abuttonright.onRelease;
          abuttonright._alpha = 30;
          }else{
          abuttonright._alpha = 100;
          }
          }

          //create incremental movement backward:
          function tweenLeft() {
          easeType = mx.transitions.easing.Strong.easeOut;
          var begin = thumbHolder_mc._x;
          var end = Math.min(0,thumbHolder_mc._x +386); // if reg point on left
          var time = 1;
          var mc = thumbHolder_mc;
          Tween = new mx.transitions.Tween(mc, "_x", easeType, begin, end, time, true);

          //disable and dim button once the thumbnail reaches the beginning:
          if (thumbHolder_mc._x > 140) {
          delete abuttonleft.onRelease;
          abuttonleft._alpha = 30;
          }else{
          abuttonleft._alpha = 100;
          }
          }

          Would totally appreciate anyone's ideas out of this snag!

          1 person found this helpful
          • 2. Re: Tween class thumbnail scrolling - trouble with button control
            giorgio789 Level 1

            Thanks so much Kglad, I did try it as is, and with few var end limit variations, but it did not work, buttons don't move the mc at all.  I did however get help from another flash forum, which works - it incorporated checkNow function, and re-enabled my buttons like I was hoping.

             

            Thank you very much again!

            giorgio