3 Replies Latest reply on Nov 12, 2010 10:16 AM by kglad

    copy motion tween as AS

    iconofsin14 Level 1

      IF you copy a motion tween as an AS how do you insert the code so that it still performs the motion?
      I created a motion tween,
      copied it,
      deleted all frames,
      made just 1 frame,
      placed the object on the frame (from the library with the same name used in the original tween)
      pasted the AS onto that frame of the relevant layer

       

      but it does not work

       

      ps this is the AS code (AS3)

      ---------------------------------------------

       

      import fl.motion.AnimatorFactory;
      import fl.motion.MotionBase;
      import fl.motion.Motion;
      import flash.filters.*;
      import flash.geom.Point;
      var __motion_Symbol1_2:MotionBase;
      if(__motion_Symbol1_2 == null) {
          __motion_Symbol1_2 = new Motion();
          __motion_Symbol1_2.duration = 24;

          // Call overrideTargetTransform to prevent the scale, skew,
          // or rotation values from being made relative to the target
          // object's original transform.
          // __motion_Symbol1_2.overrideTargetTransform();

          // The following calls to addPropertyArray assign data values
          // for each tweened property. There is one value in the Array
          // for every frame in the tween, or fewer if the last value
          // remains the same for the rest of the frames.
          __motion_Symbol1_2.addPropertyArray("x", [0,11.1304,22.2609,33.3913,44.5217,55.6522,66.7826,77.913,89.0435,100.174,111.304,122.435 ,133.565,144.696,155.826,166.957,178.087,189.217,200.348,211.478,222.609,233.739,244.87,25 6]);
          __motion_Symbol1_2.addPropertyArray("y", [0,8.08478,16.1696,24.2543,32.3391,40.4239,48.5087,56.5935,64.6783,72.763,80.8478,88.9326 ,97.0174,105.102,113.187,121.272,129.357,137.441,145.526,153.611,161.696,169.78,177.865,18 5.95]);
          __motion_Symbol1_2.addPropertyArray("scaleX", [1.000000]);
          __motion_Symbol1_2.addPropertyArray("scaleY", [1.000000]);
          __motion_Symbol1_2.addPropertyArray("skewX", [0]);
          __motion_Symbol1_2.addPropertyArray("skewY", [0]);
          __motion_Symbol1_2.addPropertyArray("rotationConcat", [0]);
          __motion_Symbol1_2.addPropertyArray("blendMode", ["normal"]);
          __motion_Symbol1_2.addPropertyArray("cacheAsBitmap", [false]);

          // Create an AnimatorFactory instance, which will manage
          // targets for its corresponding Motion.
          var __animFactory_Symbol1_2:AnimatorFactory = new AnimatorFactory(__motion_Symbol1_2);
          __animFactory_Symbol1_2.transformationPoint = new Point(0.500000, 0.500000);

          // Call the addTarget function on the AnimatorFactory
          // instance to target a DisplayObject with this Motion.
          // The second parameter is the number of times the animation
          // will play - the default value of 0 means it will loop.
          // __animFactory_Symbol1_2.addTarget(<instance name goes here>, 0);
      }

        • 1. Re: copy motion tween as AS
          kglad Adobe Community Professional & MVP

          add the following line with XXXXXXXXX replaced by an displayobject reference:

           

           

          __animFactory_Symbol1_2.addTarget(XXXXXXXXX, 0);

          1 person found this helpful
          • 2. Re: copy motion tween as AS
            iconofsin14 Level 1

            does it matter where i add it?


            is a display object referance just the object name and nothing more?

             

            ive noticed that the code has copied the object name is Symbol1_2 but in the library it is only object Symbol1, should i change every instance of this?

            • 3. Re: copy motion tween as AS
              kglad Adobe Community Professional & MVP

              change nothing in the code you posted.  place the code i suggested any place AFTER the code you posted and replace XXXXXXX with some object reference.  an object reference is the same as an instance name IF you have something placed on-stage.  if you create a displayobject with code you'll also create an object reference when you create it.  for example:

               

               

              var sp:Sprite=new Sprite();

              with(sp.graphics){

              beginFill(0x00aa00);

              drawCircle(0,0,20);

              endFill();

              }

              addChild(sp)

              __animFactory_Symbol1_2.addTarget(sp, 0);

              1 person found this helpful