Henrique
Henrique

Reputation: 145

Actionscript 3.0 MovieClip collisions

I am working on a project with a pie containing for example 8 pieces. The pie is a MovieClip and every piece is a MovieClip as well. So a circle with 8 pieces.

pie_mc.piece1_mc.addEventListener(MouseEvent.CLICK, fadeout);
pie_mc.piece2_mc.addEventListener(MouseEvent.CLICK, fadeout);
pie_mc.piece3_mc.addEventListener(MouseEvent.CLICK, fadeout);
pie_mc.piece4_mc.addEventListener(MouseEvent.CLICK, fadeout);
pie_mc.piece5_mc.addEventListener(MouseEvent.CLICK, fadeout);
pie_mc.piece6_mc.addEventListener(MouseEvent.CLICK, fadeout);
pie_mc.piece7_mc.addEventListener(MouseEvent.CLICK, fadeout);
pie_mc.piece8_mc.addEventListener(MouseEvent.CLICK, fadeout);   

What happens is that when I click on piece1_mc, some of the area of the bitmap image is overlapping piece1_mc and then this piece is fading instead of piece1_mc.

Upvotes: 2

Views: 123

Answers (1)

Aaron Beall
Aaron Beall

Reputation: 52193

Bitmaps hit area are always the full rectangle regardless of transparent areas. Probably the easiest way to solve this is to set the hitArea of each MovieClip to a pie shape:

  1. Draw a pie shape and convert it to a symbol.
  2. Place an instance of the pie shape in each MovieClip and position (rotate) it correctly.
  3. Give the pie instance a name like pieShape.
  4. Put the code hitArea = pieShape in the MovieClip. This will make the pie shape the area that the mouse interacts with.

Upvotes: 1

Related Questions