5 Replies Latest reply on Apr 11, 2008 10:36 PM by kglad

    Clip Mask and MovieClip pivot questions

    asdfhabsaf
      Two more beginner questions:

      1) What's the easiest way to invert a clipping mask for a MovieClip in ActionScript? I tried using a ColorTransformMatrix to invert the alpha of the mask MovieClip, but it didn't work (looks like the clip mask simply does nothing where there are no filled shapes). I would like to add a graphic everywhere EXCEPT within the area of an animated MovieClip, and due to various requirements I cannot simply place it behind that MovieClip.

      2) Is there a way to set the pivot of a MovieClip in relation to the animated drawings/frames? It looks like the "origin" of a movieclip is the lower left-most corner of all the bounding boxes of all the frames of animation in my MovieClip. So if I set the _x and _y of a MovieClip in ActionScript to 150,150 it places the lowerleft-hand corner there instead of what I would like to be logical center of the MovieClip (say, center of a wheelbase of a car, or center of the feet of a person, or center of mass of a rock). I am fine with dialing in an offset, but just wondering if there is a cleaner way to do it (esp. if I happen to add more animation frames or replace drawings and the bounding box changes size).

      Thanks,

      --
      Ken
        • 1. Re: Clip Mask and MovieClip pivot questions
          kglad Adobe Community Professional & MVP
          1. you have a mask and you want to "invert" the alpha of each pixel?

          2. by pivot do you mean the point around which your movieclip pivots when its _rotation is changed? if so, that's its registration point and it can be set anwhere on-stage.
          • 2. Re: Clip Mask and MovieClip pivot questions
            asdfhabsaf Level 1
            1) Yes. e.g. say I have a cheeseWedge_mc and polkaDots_mc and I want to make swiss cheese. If I do cheeseWedge_mc.setMask(polkaDots_mc) I get lots of little circular cheese dots. Is there anything I can do to get the cheeseWedge_mc to show up with circular holes in it like swiss cheese instead?

            I thought that making a ColorTransformMatrix where row 4 (the alpha row) was (0,0,0,-1,1) (i.e. newAlpha = 1-oldAlpha) would invert the mask but it seems to just make the mask disappear entirely instead.

            2) Ah, "registration point". I am really new to flash, so I did my help searches on "origin", "pivot", "center", etc.. I will check the help when I get home - thanks!


            Thanks a lot,

            --
            Ken
            • 3. Re: Clip Mask and MovieClip pivot questions
              kglad Adobe Community Professional & MVP
              1. create a polka dot movieclip consisting of many polka dots. create a bitmapdata instance and use the draw method of the bitmapdata class to create a bitmapdata instance of your polkadot movieclip. apply the palletMap method of the bitmapdata class inverting the alpha of your polkadot bitmapdata instance. attach your bitmap to a movieclip. use the movieclip with the inverted bitmap as your mask.

              you may need to enable the cacheAsBitmap property of your mask and masked movieclips.
              • 4. Re: Clip Mask and MovieClip pivot questions
                asdfhabsaf Level 1
                Ah, I figured everything out.

                1) Actually, the ColorTransformMatrix does work, but I didn't realize that alpha was 0-255, not 0-1 (you'd think after being bitten by MovieClip scales being 100 = 100% instead of 1 = 100%, I'd have guessed, but...). So a ColorTransformMatrix of
                (1 0 0 0 0)
                (0 1 0 0 0)
                (0 0 1 0 0)
                (0 0 0 -1 255)
                applied to the mask will successfully invert it. Nice.

                2) Apparently I had previously messed up grabbing all the images and dragging them - I had forgotten to turn onion skinning to "onion all" so that I could actually see everything (all my images are all on top of each other so it wasn't obvious I didn't have everything visible). I had been selecting all the frames and dragging the images around in relation to the registration point, but only the last 3 frames were actually moving, and they happened to be a part of the animation I didn't bother triggering while testing. Oops.


                Thanks much for your help.

                --
                Ken
                • 5. Re: Clip Mask and MovieClip pivot questions
                  kglad Adobe Community Professional & MVP
                  you're welcome.