2 Replies Latest reply on May 28, 2012 11:45 AM by esdebon

    Is there a way to make the Tween class move XY?

    JBonavita Level 1

      I want to move an object across the screen. For the first 10 x pixels I want it to also move 10 y pixels. So if I was manually coding it I would do

      for (i = 0; i < 10; i++) {

           x + i;

           y +i

      }

       

      Once it gets to the max x position I want it to reverse y.

       

      At the same time I would like to reduce the size of the object for the same by 1% while moving y and then reversing it back to the normal size at when the y is reversed.

       

      I think maybe the size can be done with the transition but I'm not sure.

       

      Thanks for any help.

       

      Joe.

        • 1. Re: Is there a way to make the Tween class move XY?
          JBonavita Level 1

          Can the tween class be used on the 3D properties?

          • 2. Re: Is there a way to make the Tween class move XY?
            esdebon Level 4

            Where object is the instance name of the object to move

             

             

            import fl.transitions.Tween;

            import fl.transitions.TweenEvent;

             

            var xTween:Tween;

            var yTween:Tween;

            var yScale:Tween;

            var XScale:Tween;

             

            var initX:Number;

            var initY:Number;

            var finishX:Number;

            var finishY:Number;

            var timeTweens:int = 5;

             

            var newScaleX:Number=0.3;

            var newScaleY:Number=0.3;

             

            xTween = new Tween(object,"x",Strong.easeOut,initX,finishX,timeTweens,true);

            yTween = new Tween(object,"y",Strong.easeOut,initY,finishY,timeTweens,true);

            xTween.addEventListener(TweenEvent.MOTION_FINISH, reverseY);

             

             

            function reverseY(e:TweenEvent):void{

                yTween = new Tween(object,"x",Strong.easeOut,finishY,initY,timeTweens,true);

               

                XScale = new Tween(object,"scaleX",Strong.easeOut,1,newScaleX,timeTweens,true);

                yScale = new Tween(object,"scaleY",Strong.easeOut,1,newScaleY,timeTweens,true);

            }