1 Reply Latest reply on Dec 5, 2009 8:16 AM by robdillon

    Tween problems in ActionScript 3.0




      I'm stuck with my problem and I have no idea what is wrong. I'm making movement of movie clip via creating new Tween in Action Script 3, Flash CS4 and it happens, when I mouse over button in another movie clip. The problem is that movement sometimes work perfectly, but sometimes it gets stuck in middle of movement and continues only if I mouse over again. Here is the code of function of first frame in main scene:


      import fl.transitions.Tween;
      import fl.transitions.easing.*;
      function btnOver(I:Number) {
      var tw: Tween = new Tween(somemovieclip, "x", Strong.easeOut, somemovieclip.x, I, 1, true);
      Here is how I'm calling that function from another movie clip when I mouse over a button:


      function over(eventObject:MouseEvent) {
      (root as MovieClip).btnOver(288);
      btn.addEventListener(MouseEvent.MOUSE_OVER, over);
      I have several motions like this - for each button different variable for x position (number "I"). I also have another movie clip playing at the same time, but it isn't connected with any of movie clips mentioned above.


      Does anybody have an idea what is wrong?


      P.S.: I'm on Mac with latest flash player and movie works better in Windows - it has less mistakes, but still they happen very rare. Probably the problem is somewhere inside player or something like that?



        • 1. Re: Tween problems in ActionScript 3.0
          robdillon Most Valuable Participant

          It looks like the problem is that you only have one Tween instance to work with. If you start one tween and start another before the first has completed, the first one has to stop working because that one Tween instance has to jump over to the new tween that's just been called.


          You probably want to set up an individual tween for each button. You might also want to look into using something like TweenLite/TweenMax instead of the built in Flash tweening. Have a look at: http://blog.greensock.com/tweenmax/