5 Replies Latest reply on Sep 14, 2010 8:49 AM by Ned Murphy

    Motion Tween.

    Rig0z Level 1

      Hello!    

      I have a big problem on a project that I'm developing.

      I've created an animation with ActionScript 2.0 using mx Tween class.

       

      This is the code:

      import mx.transitions.Tween;
      import mx.transitions.easing.*;
      var myTween:Tween = new Tween(mc1, "_y", Regular.easeOut, mc1._y, mc1._y-100, 0.8, true);
      var listeningObject:Object = new Object();
      myTween.addListener(listeningObject);
      listeningObject.onMotionFinished = function():Void {

           this.mc1.gotoAndStop(1);

      }

       

      The first time the animation work well, but when i try to execute again by button on first frame of my scene the motion not execute standard motion tween and execute only final parts of this code.

      I've tried to insert a trace and flash send to me this information: [Tween]

      I think I can't exit or delete or stop or reset this Tween.

       

      Immagine.JPG

       

      The code work well but I can't do a "rewind" of all the scene!

      After the tween I want to see the standard motion...

      Please help me if you can.

      Bye!

        • 1. Re: Motion Tween.
          Ned Murphy Adobe Community Professional & MVP

          It might just be me, but I have a feeling that you are having a bigger problem explaining your problem.  From your description I cannot begin to undertsand what your problem is nor what you are trying to accomplish.

          • 2. Re: Motion Tween.
            Rig0z Level 1

            I'm so sorry for my english.

            The problem that I want to explain is very simple!

             

            I want to re-execute the motion tween of the blue square after an ActionScript tween.

             

            Example:

            In frame 1 to 20 I create a motion tween who move the blue square from left to right.

            In frame 21 I wrote an AS 2.0 code that implement mx.transitions.tween class.

             

            Like that:

            import mx.transitions.Tween;
            import mx.transitions.easing.*;
            var myTween:Tween = new Tween(mc1, "_y", Regular.easeOut, mc1._y, mc1._y-100, 0.8, true);
            var listeningObject:Object = new Object();
            myTween.addListener(listeningObject);
            listeningObject.onMotionFinished = function():Void {

                 this.mc1.gotoAndStop(1);

            }

             

            mc1 is the movieclip that contain my square.

             

            The problem is about the this.mc1.gotoAndStop(1). The flash still re-execute only the actionscript code.

            I want to return to frame 1 and have the square in its first position.

            • 3. Re: Motion Tween.
              Ned Murphy Adobe Community Professional & MVP

              How does telling the mc1 to goto and stop at its frame 1 have to do with going back to frame 1 of the timeline tween and playing it again?  Wouldn't you want to use...

               

              listeningObject.onMotionFinished = function():Void {

                   this.gotoAndPlay(1);

              }

              1 person found this helpful
              • 4. Re: Motion Tween.
                Rig0z Level 1

                No.

                It doesn't work.

                 

                When the Actionscript tween is executed Flash couldn't return to the frame 1.

                It seem that the timeline is freezed.

                When I do a new operation (like press a button on the scene or on the keyboard) Flash jump immediatly on the ActionScript.

                 

                I can't see the motion from the frame1.

                 

                Can I send you a small example?

                 

                Thank you very much for yours replies.

                • 5. Re: Motion Tween.
                  Ned Murphy Adobe Community Professional & MVP

                  First, try moving that very last frame to a layer of its own, separate from the timeline tween layer.  I think it breaks the motion tween by having it on the same layer.  Also, change the code to...

                   

                  stop();

                  import mx.transitions.Tween;
                  import mx.transitions.easing.*;
                  var myTween:Tween = new Tween(mc1, "_y", Regular.easeOut, mc1._y, mc1._y-100, 0.8, true);
                  myTween.onMotionFinished = function():Void {
                       _root.gotoAndStop(1);
                  }