1 Reply Latest reply on May 13, 2006 7:13 AM by blemmo

    forcing onPress to react on the exact shape, rather then on the bounding box

    Level 7
      If I have a clip with an imported image then clip.onPress reacts on the
      bounding box of the clip rather then on the exact shape of the imported
      image even if the imported image has a transparent background.
      To make it to react to in image shape only I have to use Trace BitMap which
      results in deterioration of the image quality and if the clip is moving,
      Trace BitMap also slows down computer perfprmance.
      Is there other technique to make onPress to react on the exact shape, rather
      then on the bounding box?


        • 1. Re: forcing onPress to react on the exact shape, rather then on the bounding box
          blemmo Level 1
          An image is always rectangular, it just may have transparent parts. So an MC containing an image is always as big as the whole image (at least).
          You could use the MovieClip.hitArea property, and create another MC inside your clip that specifies the active area for mouse clicks. This is easy if you have the image loaded into the clip inside the Flash IDE.
          If it's loaded on runtime, you might use the BitmapData class (if you use Flash 8) to get the pixel value of the image at the position where the image was clicked, check if it's transparent or opaque, and decide whether to call the onPress action or not.

          hth,
          blemmo