1 Reply Latest reply on Jun 26, 2006 11:03 AM by Peter Lorent

    Tweening Class: Problems

    Addicted_to_Colour
      Hi, I use the tweening class a lot in my sites. The problem i have though is that things go crazy when a user presses to many buttons and a ton of tweens get implemented.

      A simple example is below where a button is pressed, the target clip fades out to 0 alpha, then back to 100. I use that kind of thing alot where an image is loaded into the clip between the two alpha tweens.

      The problem is that if the user presses the button, then presses it again before the tween is done it will blink at 100% alpha, or just stay there (and if it's pressed a bunch of times it just goes crazy) . . . either way it doesn't work smoothly. And this doesn't just apply to tweening the alpha . . . there must be some way to override the current tween with the new one. What am I doing wrong?

      button.onRelease = function() {
      var alpha_tween:Tween = new Tween(target, "_alpha", Regular.easeOut, target._alpha, 0, 1, true);
      alpha_tween.onMotionFinished = function() {
      var alpha_tween2:Tween = new Tween(target, "_alpha", Regular.easeOut, target._alpha, 100, 1, true);
      }
      }

      oh and I also do not want to disable my button until the tween is finished . . . Thanks in advance!
        • 1. Re: Tweening Class: Problems
          Peter Lorent Level 2
          When a user clicks another button you have to delete the current tweens and (depending on your setup) reset the visual state of the 'previous' button. If you don't want to disable the button during a tween you still have a problem when a user repeatedly clicks the button. An option might be to use a Boolean and only start a new tween when that Boolean is false. Personally I wouldn't code the tweens on the buttons but I would use a function and call that function from the buttons.