5 Replies Latest reply on Jun 22, 2010 11:18 PM by kglad

    Move Object from Current Postition

    flashQman

      Hi,

       

      I'm looking to see how to move an object from it's current position to a designated _x coordinate.  I want current position to be a variable that has it track where it is currently located and travel automatically without having to say move from 24.7 to 35.8, for example. I'm usuing the basic mx tweener classes and would like to keep it that way.  Basically I'm creating a nav where a dot flies to the nav selection. So end result is I want code that says travel to this _x coordinate from wherever you currently are.

       

      Thanks!

        • 1. Re: Move Object from Current Postition
          kglad Adobe Community Professional & MVP

          do you know how to use the tweener class?  if so, what's the problem?  if not, why are you using it?

          • 2. Re: Move Object from Current Postition
            flashQman Level 1

            Yes, I know enough to get by but I'm probably not using it to it's full   potential.  Here's how I'm currently accomplishing what I want, which   works fine, but it would be nice if it were cleaner.

             

            navHome.onRelease = function() {
                 if (navBullet._y == -360) {
                      bulletTween = new Tween(navBullet, "_y", Back.easeOut, -360, -402, 1.5, true);
                 }
            
                 if (navBullet._y == -319) {
                      bulletTween = new Tween(navBullet, "_y", Back.easeOut, -319, -402, 1.5, true);
                 }
            
                 if (navBullet._y == -279) {
                      bulletTween = new Tween(navBullet, "_y", Back.easeOut, -279, -402, 1.5, true);
                 }
            
                 if (navBullet._y == -237) {
                      bulletTween = new Tween(navBullet, "_y", Back.easeOut, -237, -402, 1.5, true);
                 }
            
                 if (navBullet._y == -196) {
                      bulletTween = new Tween(navBullet, "_y", Back.easeOut, -196, -402, 1.5, true);
                 }
            
            };
            
            
            • 3. Re: Move Object from Current Postition
              kglad Adobe Community Professional & MVP

              1.  that's not the tweener class.  that's the tween class.

               

              2.  you can put all those if-statements in one line and use one tween function:

               


               

              navHome.onRelease = function() {
                   if (navBullet._y == -360 || navBullet._y==-319||navBullet._y==-279||navBullet._y==-237||navBullet._y==-196) {
                        bulletTween = new Tween(navBullet, _y, Back.easeOut, navBullet._y, -402, 1.5, true);
                   }
              };


              • 4. Re: Move Object from Current Postition
                flashQman Level 1

                Oops, sorry for the mis quote.  Thank you so much for the shorthand, I was not aware of the || usage.

                • 5. Re: Move Object from Current Postition
                  kglad Adobe Community Professional & MVP

                  ||  is logical "or"

                   

                  && is logical "and"