2 Replies Latest reply on Jul 22, 2009 1:37 AM by chrisatflash

    Timeline bug after applying a color to a movieclip?

    chrisatflash Level 1

      Hello,
      I asked some flashers to take a look at my problem, but they did not know what happed or why it happend.

       

      If you apply a color to a movieclip within a timeline, you also destroy the animation so it seems.

      I enclosed the fla file for test purpuse. But what i am doing is:

       

       

      I have a main clip called animation and in this clip the playhead goes from frame 1 to 30

      Inside this animationclip i have a square called myclip that also does some animation.

      But when you apply a color to this square and you run the animationclip, you will notice that

      the square does not animate anymore. But the playhead still runs, so that is weird isn't it?

       

      Does anyone know the answer to this bug ?

       

      The code i used is:

       

      function applyColor(mc:MovieClip, col:Number) {

      var tempColor:Color = new Color(mc);

      tempColor.setRGB(col);

      }

       

       

      mybutton.onRelease = function() {

      applyColor(animation.myclip, 0xFFCC00);

      }

       

      mybutton2.onRelease = function() {

       

      animation.gotoAndPlay(2);

      }

       

       

      Regards,

       

      Chris

        • 1. Re: Timeline bug after applying a color to a movieclip?
          MaxManNH

          Don't know if you have already solved this, but the issue is you have a timeline animation and when you change a property like the color of the movieclip you are actually changing the movieclip in the first frame of the animation which causes a disassociation between the first frame and the rest of the animation and destroys the tween.

           

          2 solutions.

           

          1. just double click into myClip and highlight the gray block and make it into a movieclip called colorBlock with an instance name of cb. Then use the following code.

           

               import flash.geom.ColorTransform;
          import flash.geom.Transform;

           

          function applyColor(mc:MovieClip, col:Number) {
              var trans:Transform = new Transform(mc);
              var ct:ColorTransform = new ColorTransform();
              ct.rgb = col;
              var tempColor:Color = new Color(mc);
              trans.colorTransform = ct;
          }

           


          mybutton.onRelease = function() {
              applyColor(animation.myclip.cb, 0xFFCC00);
          }

           

          mybutton2.onRelease = function() {
             
              animation.gotoAndPlay(2);
          }

           

          2. Use programmatic tweens. I find them to be more robust and almost impossible to break. I would advise using Moses Gunesch's tweening engine for AS2 called the FuseKit. You can find it at www.mosessupposes.com/fuse

          • 2. Re: Timeline bug after applying a color to a movieclip?
            chrisatflash Level 1

            Thanks for your information! This workaround works great!
            But i agree with the fact that tween engines are more powerfull, i never used FuseKit, but it looks very clean and effective.

            Regards,
            Chris.