10 Replies Latest reply on Oct 20, 2006 5:40 PM by kglad

    2nd tween not working

    s-atoms
      Can anyone explain why the following tween in Frame2 of the main timeline doesn't work? The 1st works fine.

      Frame1
      var twMoveClip:Object = new Tween(this.mcMenu.mcB, "_y", Strong.easeInOut, 196, 0, 20, false);
      twMoveClip.onMotionFinished = function():Void {trace("finished"); delete twMoveClip;}

      Frame2
      var nY:Number = this.mcMenu.mcB._y;
      var twMoveClip:Object = new Tween(this.mcMenu.mcB, "_y", Strong.easeInOut, 0, 196, 20, false);
        • 1. Re: 2nd tween not working
          TimSymons Level 1
          Do you have stop(); actions on these frames? Can you post all of the code for each of the 2 frames? It doesn't seem to be a syntax issue with the code you posted but it may have something to do with your other code.

          Also, you shouldn't have to delete the twMovieClip variable after the tween is finished, since you are using it again for the other tween.

          Tim
          • 2. Re: 2nd tween not working
            kglad Adobe Community Professional & MVP
            does frame 2 play before your onMotionFinished executes?
            • 3. Re: 2nd tween not working
              s-atoms Level 1
              The full code is as follows. I only added the delete to try and get the code to work. There is a button in frame 1 which when released goes to frame 2 and stops & another which goes to Frame 3 and stops. In theory i could press the buttons before the tween has finished but i generally havent.

              <b>Frame 1</b>
              import mx.transitions.Tween;
              import mx.transitions.easing.*;

              fscommand("allowscale", "false");
              this.mcMenu.mcB.setMask(this.mcMenu.mcMask);
              //this.b1.onRelease = function():Void {gotoAndStop(2);} // logon
              //this.b2.onRelease = function():Void {gotoAndStop(3);} // display leagues
              //this.b3.onRelease = function():Void {gotoAndStop(4);} // contact
              //this.b4.onRelease = function():Void {gotoAndStop(7);} // register

              _global.user = "";
              var twMoveClip:Object = new Tween(this.mcMenu.mcB, "_y", Strong.easeInOut, 196, 0, 20, false);
              //twMoveClip.onMotionFinished = function():Void {trace("finished"); delete twMoveClip;}
              stop();

              <b>Frame 2</b>
              var nY:Number = this.mcMenu.mcB._y;
              var twMoveClip:Object = new Tween(this.mcMenu.mcB, "_y", Strong.easeInOut, 0, 196, 20, false);
              stop();

              <b>Frame 3</b>
              var nY:Number = this.mcMenu.mcB._y;
              twMoveClip = Tween(this.mcMenu.mcB, "_y", Strong.easeInOut, 0, 392, 20, false);
              stop();
              • 4. Re: 2nd tween not working
                kglad Adobe Community Professional & MVP
                i thought you must have misnamed (or failed to name mcMenu) on frame 2. but on testing i found a tween is not defined on frame 2 when the import statements are on frame 2. i don't have time right now to track down the problem.

                i notice that you're typing your tween as an object. but that's not causing the problem. if you more correctly typed your tween as Tween the compiler would return an error allowing you to see the issue.

                anyway, for some reason you need your import statements on frame 2.
                • 5. Re: 2nd tween not working
                  s-atoms Level 1
                  When frame 1 has completed and is waiting for a button press (to move to frame 2 or 3) the following objects exist.......

                  Level #0: Frame=1
                  Movie Clip: Frame=1 Target="_level0.instance34"
                  Shape:
                  Text:
                  Text:
                  Movie Clip: Frame=1 Target="_level0.mcMenu"
                  Movie Clip: Frame=1 Target="_level0.mcMenu.mcB"
                  Button: Target="_level0.mcMenu.mcB.b1"
                  Movie Clip: Frame=1 Target="_level0.mcMenu.mcB.b1.instance35"
                  Shape:
                  Text:
                  Button: Target="_level0.mcMenu.mcB.b2"
                  Movie Clip: Frame=1 Target="_level0.mcMenu.mcB.b2.instance36"
                  Shape:
                  Text:
                  Button: Target="_level0.mcMenu.mcB.b3"
                  Movie Clip: Frame=1 Target="_level0.mcMenu.mcB.b3.instance37"
                  Shape:
                  Text:
                  Button: Target="_level0.mcMenu.mcB.instance38"
                  Movie Clip: Frame=1 Target="_level0.mcMenu.mcB.instance38.instance39"
                  Shape:
                  Text:
                  Button: Target="_level0.mcMenu.mcB.instance40"
                  Movie Clip: Frame=1 Target="_level0.mcMenu.mcB.instance40.instance41"
                  Shape:
                  Text:
                  Button: Target="_level0.mcMenu.mcB.instance42"
                  Movie Clip: Frame=1 Target="_level0.mcMenu.mcB.instance42.instance43"
                  Shape:
                  Text:
                  Button: Target="_level0.mcMenu.mcB.instance44"
                  Movie Clip: Frame=1 Target="_level0.mcMenu.mcB.instance44.instance45"
                  Shape:
                  Text:
                  Button: Target="_level0.mcMenu.mcB.instance46"
                  Movie Clip: Frame=1 Target="_level0.mcMenu.mcB.instance46.instance47"
                  Shape:
                  Text:
                  Button: Target="_level0.mcMenu.mcB.instance48"
                  Movie Clip: Frame=1 Target="_level0.mcMenu.mcB.instance48.instance49"
                  Shape:
                  Text:
                  Button: Target="_level0.mcMenu.mcB.instance50"
                  Movie Clip: Frame=1 Target="_level0.mcMenu.mcB.instance50.instance51"
                  Shape:
                  Text:
                  Button: Target="_level0.mcMenu.mcB.instance52"
                  Movie Clip: Frame=1 Target="_level0.mcMenu.mcB.instance52.instance53"
                  Shape:
                  Text:
                  Movie Clip: Frame=1 Target="_level0.mcMenu.mcMask"
                  Shape:
                  Movie Clip: Frame=0 Target="_level0.__OnEnterFrameBeacon"
                  Movie Clip: Frame=1 Target="_level0.focusManager"
                  Button: Target="_level0.focusManager.tabCapture"
                  Shape:
                  Movie Clip: Frame=1 Target="_level0.focusManager.instance54"
                  • 6. Re: 2nd tween not working
                    TimSymons Level 1
                    I agree with kglad. Your code looks fine so just make sure that the layer that contains the "mcMenu.mcB" clip does not have keyframes on each frame. You should only need the keyframe on frame 1. If you do have keyframes for this layer on frames 2, 3, etc. You may want to give them different instances names and then change your code to reflect this for each frame.

                    I have experience intermittent issues with succesive keyframes giving the mc the same instance names. Sometimes the code would work but most of the time it was ignored after the first keyframe.

                    Tim
                    • 7. Re: 2nd tween not working
                      s-atoms Level 1
                      Thanks, but the menu layer only has one keyframe in frame 1...

                      Whats the best way to debug a problem like this? ... i find flash infuriating when something doesn't work when i think it should.
                      • 8. Re: 2nd tween not working
                        TimSymons Level 1
                        As kglad suggested you could put your import statements on the other frames or you could re-write the code to look like this:


                        This defines a function that you can call with various parameters allowing you to only have to use the import statements on the first frame.

                        Tim



                        • 9. 2nd tween not working
                          s-atoms Level 1
                          Thanks guys

                          Including the imports in frames 2& 3 solves the problem.

                          I've also changed the tweens to type Tween rather than Object and the same situation exists.

                          Thanks again
                          • 10. Re: 2nd tween not working
                            kglad Adobe Community Professional & MVP
                            you're welcome.