7 Replies Latest reply on Oct 29, 2010 10:17 AM by Ned Murphy

    dynamic tween in AS 2.0

    SCgroove Level 1

      Greetings.  I'm very used to Actionscript 3.0 by now, but every now and then I get jobs where I have to blow cob webs off of the Actionscript 2.0 part of my brain ... Easier said then done sometimes ... anyway, I'm trying to do a dynamic tween that is triggered by the onRelease event. The end destination of the tween will be dynamiclly set each time the left or right arrow button is clicked ... what will happen is, a long movieClip filmstrip containing different images will scroll to the appropriate _x coordinate to align the correct image.  My trouble is with my syntax I think ... the error is saying the function needs to be inside of the "on" event?  Also it's telling me that the Tween class can't be loaded?  Can anbody point me in the right direction?  This is much easier (at least to me) in AS 3.0.

       

      Here's my code for the rightButton_mc.  There will also be a left button to move the filmstrip left, but I figured I could just get the rightButton_mc up and running first.

       

      Thanks

      | scott

       

      // --- imports

      import mx.transitions.Tween;
      import mx.transitions.easing.*;

       

      //---determine "end" variable
      on (release) {
      if(sectionsStrip_mc._x == 0){
          end = 450;
      } else if(sectionsStrip_mc._x == 450){
          end = 900;
      } else if(sectionsStrip_mc._x == 900){
          end = 1350;
      } else(sectionsStrip_mc._x == 1350){
          end = 1800;
      }

          filmTweenRight();
      }

       

      //---tweeningfunction
      function filmTweenRight()
      {
          var mcTween:Tween = new Tween( sectionsStrip_mc, "_x", Regular, sectionsStrip_mc, end, 1, true );
      }

        • 1. Re: dynamic tween in AS 2.0
          Ned Murphy Adobe Community Professional & MVP

          If that code is all planted "on" an object, that might the source of the problem.  Try following the AS3 protocol of keeping the code on the timeline. Instead of using "on" on the object, try using...

           

          btnName.onRelease = function(){

             etc...

          }

           

          on the timeline like you would in AS3.

          1 person found this helpful
          • 2. Re: dynamic tween in AS 2.0
            SCgroove Level 1

            I'll try that now ... didn't know you could do that in AS 2.0.

             

            Any idea why my Tween class and it's Easing won't import?

            • 3. Re: dynamic tween in AS 2.0
              Ned Murphy Adobe Community Professional & MVP

              Same response... it may all be related to having that code on an object.  See if it works first, otherwise, your import statements are correct so there will be a mystery to solve.

              1 person found this helpful
              • 4. Re: dynamic tween in AS 2.0
                SCgroove Level 1

                I'm getting there ... it turned out I had to have the function inside of the "on" statement ... that's weird, but as long as it works. Once you have AS 3 on your brain ...

                 

                I'm having a totally new problem now ... and that is, Flash is completely blowing off the tween event.  If you look at the code below, the one line that I have commented out (//sectionsStrip_mc._x = endX_right;), that was just a temporary work around to see if everything else works.  It does.  If I leave out the tween all together and just update my _x property with new values, it works.  Now I 'd like to get it to animate with the tween class.  The way I have it below, it just doesn't acknowledge the tween.  I'm wondering (even though I Googled it already) if maybe that tween statement construct that I have is exclusive to AS 3.0?

                 

                 

                //---determine "end" variable
                on (release) {
                    if(sectionsStrip_mc._x == 0){
                        endX_right = -450;
                        filmTweenRight();
                    } else if(sectionsStrip_mc._x == -450){
                        endX_right = -900;
                        filmTweenRight();
                    } else if(sectionsStrip_mc._x == -900){
                        endX_right = -1350;
                        filmTweenRight();
                    } else if(sectionsStrip_mc._x == -1350){
                        endX_right = -1800;
                        filmTweenRight();
                    }

                 

                //---tweeningfunction
                function filmTweenRight()
                {
                    //sectionsStrip_mc._x = endX_right;
                    new Tween(sectionsStrip_mc, "_x", Regular, sectionsStrip_mc, endX_right, 1, true);
                }

                 

                }

                • 5. Re: dynamic tween in AS 2.0
                  Ned Murphy Adobe Community Professional & MVP

                  I have picked up on this in your newer posting.  You should stick with a posting if you want to resolve it, but if you prefer to get someone else's help, start another and I will avoid it.

                  • 6. Re: dynamic tween in AS 2.0
                    SCgroove Level 1

                    It wasn't that I needed somebody else ... I just asked the question right at the rush hour commute and wasn't getting a response, so I posted it again.

                     

                    Thanks for all your help Ned!

                     

                    | scott

                    • 7. Re: dynamic tween in AS 2.0
                      Ned Murphy Adobe Community Professional & MVP

                      Patience...