3 Replies Latest reply on May 29, 2009 11:26 PM by kglad

    "negative" fill


      I'm very new to Flash but starting to get the hang of it.


      However I've run into a bit of a snag with a project I'm working on.


      I basically want to make an animation with an effect similar to the one when you select a portion of an image using the crop tool (background very dark and the selected area unaffected). I have discovered a few different ways to do it, the easiest so far to bring in my bitmap image, lock it in a layer, then put a rectangle the same size and shape as the image in front, fill it with black with an alpha of 50% and then delete parts of the rectangle in the places i want to highlight. Then I drag the edges of the cutouts in to fill the cutout, and use a shape tween to animate. However, I would like these "highlighted" areas to be clickable buttons, and I would not like to have to make a custom layer every time I want to use this animation for a diferent background image (since I will always be highlighting different areas of different images)


      So my question is: is there any way to make a "negative object" (for lack of a better term) meaning an object whose fill removes the fill from the object behind it. This would make things much simpler to duplicate for different images over and over again.


      Thanks in advance for any responses.

        • 1. Re: "negative" fill
          kglad Adobe Community Professional & MVP

          will the highlighted regions always be rectangular or circular or elliptic?  and are you using as2 or as3?

          • 2. Re: "negative" fill
            mhig9000 Level 1

            I'm using AS3 and the areas could be either rectangular or elliptical (i was hoping for circular but square or rectangular would work fine for my purposes).

            • 3. Re: "negative" fill
              kglad Adobe Community Professional & MVP

              you can use the function below the dotted line.  just pass the movieclip you want to highlight, the highlight shape ("rect" or "ellipse") and the highlight data (which is an object with x,y,width,height properties).


              for example, to highlight a movieclip mc with an elliptical shape at 10,20 with width =100 and height=40 use:






              //----------------------- nothing below this line needs editing ------------------------------

              function highlightF(mcToHighlight:MovieClip,highlightShape:String,highlightData:Object){
                  var cover:Sprite = new Sprite();
                  var holeSP:Sprite = new Sprite();
                      } else {
                  var bmpd:BitmapData = new BitmapData(cover.width,cover.height,true,0x00000000);
                  var bmp:Bitmap = new Bitmap(bmpd);