9 Replies Latest reply on Jan 19, 2009 5:17 PM by clbeech

    invert color of movie clip?

    shintashi Level 1
      I'm trying to invert the colors of various movieclips on collision detection (as opposed to blanking them with one color) and was wondering if there is a method of doing this, especially if the original colors aren't specified.

      This is something that could be used for hundreds or thousands of different MCs.
        • 1. Re: invert color of movie clip?
          clbeech Level 3
          you could use the Blend modes to do this. one important thing about use them is that you must make sure the the 'parent' object's Blend mode is set to 'layer' which effects nothing else but allows certain modes to be used.
          • 2. Re: invert color of movie clip?
            Rothrock Level 5
            You can also use the Color.setTransform() or better yet the ColorTransform class to do this. I think for the multipliers you want are -1 and for the offsets 255. (Those are only for the RGB, leave the alpha alone.)
            • 3. Re: invert color of movie clip?
              shintashi Level 1
              ok, so I've got

              as my base template;

              ColorTransform([redMultiplier:Number], [greenMultiplier:Number], [blueMultiplier:Number], [alphaMultiplier:Number], [redOffset:Number], [greenOffset:Number], [blueOffset:Number], [alphaOffset:Number])

              then I stick that in some kind of variable, like

              var mc_invert = ColorTransform(...);
              invertColor = ColorTransform(test_mc);
              invertColor.ColorTransform(mc_invert);

              ... I don't think I'm parsing this right, and I haven't got a clue what goes in "redMultiplier:Number" or "redOffset:Number"

              I'm going to guess

              ColorTransform([redMultiplier:-1, [greenMultiplier:-1], [blueMultiplier:-1], [redOffset:255], [greenOffset:255], [blueOffset:Number])

              ??
              • 4. Re: invert color of movie clip?
                shintashi Level 1
                I found this, and assume 255 goes in the offset and -1 in the multiplier,

                ColorTransform([redMultiplier:Number], [greenMultiplier:Number], [blueMultiplier:Number], [alphaMultiplier:Number], [redOffset:Number], [greenOffset:Number], [blueOffset:Number], [alphaOffset:Number])


                but what method is used to parse it?

                I tried

                var invert_mc = ColorTransform(redMultiplier:-1, greenMultiplier:-1, blueMultiplier:-1, redOffset:255, greenOffset:255, blueOffset:255)

                and get the error:

                ')' or ',' expected
                • 5. Re: invert color of movie clip?
                  kglad Adobe Community Professional & MVP
                  try:

                  import flash.geom.*;
                  var ct1:ColorTransform = new ColorTransform(-1,-1,-1,1,255,255,255,0);
                  test_mc.transform.colorTransform = ct1;
                  • 6. Re: invert color of movie clip?
                    shintashi Level 1
                    quote:

                    Originally posted by: kglad
                    try:

                    import flash.geom.*;
                    var ct1:ColorTransform = new ColorTransform(-1,-1,-1,1,255,255,255,0);
                    test_mc.transform.colorTransform = ct1;




                    I would have never thought to use import (my color skills suck);


                    is there a way to revert to the colors before invert when not colliding? like storing the first color string in a temp variable then sticking it back into place when collision detection is false?
                    • 7. Re: invert color of movie clip?
                      clbeech Level 3
                      i believe you can set the colorTransform property of the clip back to 'null' to accomplish that.
                      • 8. Re: invert color of movie clip?
                        kglad Adobe Community Professional & MVP
                        :

                        // before executing any transforms on test_mc
                        test_mc.origCT = test_mc.transform.colorTransform;

                        // then any time you want to restore a movieclip like test_mc's color transform:

                        test_mc.transform.colorTransform = test_mc.origCT;
                        • 9. Re: invert color of movie clip?
                          clbeech Level 3
                          DOH! was thinking of filters LOL! :)