3 Replies Latest reply on Aug 30, 2007 4:47 AM by zoenoble

    dynamic mask? how do I make cursor act as a spray can?

    zoenoble
      I'm trying to make a mask act like a apray can. So when when the cursor moves over a particular place on my page, it will reveal an image below, as if it were spraying away the top layer.
      I have seen this effect before, but I cannot find any tutorials for it anywhere

        • 1. Re: dynamic mask? how do I make cursor act as a spray can?
          kglad Adobe Community Professional & MVP
          you can use the bitmapdata class and to build a mask that starts with an alpha of zero and then is "merged" (using the merge method of the bitmapdata class) with an alpha gradient - your spray mc "drawn" (use the movieclip draw method).

          you must enable the cacheAsBitmap properties of your masked movieclip/display object and the masking movieclip/display object.
          • 2. Re: how do I make a mask  'spray' effect
            Level 7
            In addition to what kglad said, you can also do something as simple as
            attaching circle shapes into a mask clip, around the mouse point. I just did
            this as a little test and it worked pretty well:

            var cnt:Number = 1;
            var ang:Number;
            pic.setMask(theMask);
            this.onMouseDown = function() {
            ang = 0;
            theMask.onEnterFrame = function() {
            var s = Math.random() * 200 + 30;
            this.attachMovie("droplet", "drop" + cnt, this.getNextHighestDepth(),
            {_x:this._xmouse + (Math.sin(ang) * 5), _y:this._ymouse + (Math.cos(ang) *
            5), _xscale:s, _yscale:s});
            cnt += 1;
            ang += .5;
            if (ang > 360) {ang = 1;}
            };
            };
            this.onMouseUp = function() {
            delete theMask.onEnterFrame;
            };

            Paste into frame 1 - there's a clip on stage named pic, and an empty clip
            above it named theMask - droplet is the linkage id of a small circle shape
            clip in the library.

            It's quite simple and may not be exactly what you're looking for, but it may
            give you a start.



            --
            Dave -
            Head Developer
            http://www.blurredistinction.com
            Adobe Community Expert
            http://www.adobe.com/communities/experts/


            • 3. Re: how do I make a mask  'spray' effect
              zoenoble Level 1
              Hi Dave, thank you so much for this..this is exactly the kind of thing i'm after! The only problem I have is that I need four versions of this. So on my page there are 4 small images (hairspray bottles in fact), and when a person clicks on one of these different bottles they can then 'spray' the corresponding information for that bottle.

              Ideally I would love to have the user click on a bottle, and the cursor becomes that bottle, they can then 'spray' in the area, read the info about the product and then go to another bottle and the same thing happen.

              Any help would be much appreciated.

              Zoe