Flash AS3 lets <mouse click> penetrate the upper transparent area, and the lower object triggers the <mouse click> event

Problem description:
1. Place 2 Sprites, A and B on the Stage, their center area and border are opaque, while the edge area is transparent

2. A is on top of B, and there is an overlapping area between A and B, as follows Figure
  (* is the central area of ​​A, . is the central area of ​​B, the blank space is the transparent area, and X is the mouse click area) 3. When clicking on the X position, if you let B respond to the event   A--------- ---A   | |   | ****** |   | ******---+------B   | ****** | |   | | ...|... |   | | .X.|... |     | | ...|... |   A----+------A... |   | ................... |   | |   B -------------B ------------------------------------ -------------------- Solution -------------------------------------- ---------------------------- Use the InteractivePNG tool InteractivePNG to make transparent pixels in PNG images no longer responsive to mouse interaction. The class file involved is com/ibio8/media/images/MCInteractivePNG.as
   
















                             






http://www.mosessupposes.com/utilities/
overview The

main function of this class is to treat transparent areas of PNG images as areas without mouse events. In order to facilitate the operation of mouse events and collision detection for MCs containing transparent bitmaps.
Use method

mybtn1.addEventListener(MouseEvent.MOUSE_OVER, mouseHandler1);
mybtn1.addEventListener(MouseEvent.MOUSE_OUT, mouseHandler1);
function mouseHandler1(evt:Event):void {
if (evt.type=="mouseOver") {
bg1.gotoAndStop( 2);
} else {
bg1.gotoAndStop(1);
}
}

mybtn2.addEventListener(MouseEvent.MOUSE_OVER, mouseHandler2);
mybtn2.addEventListener(MouseEvent.MOUSE_OUT, mouseHandler2);
function mouseHandler2(evt:Event):void {
if (evt .type=="mouseOver") {
bg2.gotoAndStop(2);
} else {
bg2.gotoAndStop(1);
}
}
Key analysis
example:
http://www.mosessupposes.com/utilities/InteractivePNG_demo.html How

to use: After downloading the demo, you need to put it in the same directory as the tool package and use it.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326436257&siteId=291194637