Skip to main content
AndrewYuCWA1987
Known Participant
December 20, 2011
Question

how to avoid transparent part of bitmap to react with mouse events?

  • December 20, 2011
  • 1 reply
  • 1087 views

Hi, there.

What I have is a bitmap as render cache for a sprite, and there're many of them present on the stage. I expected that they would react like sprites with mouse-click event, but they didn't. They're like rectangles all around, matter what the original sprite look like, And I tried put bitmap cache into sprite container and use sprite's hitArea property like:

var container:Sprite = new Sprite();

container.addChild(bitmapCache);

container.hitArea = someSpriteMadeUp;

OK, container sprite now only react with mouse according to "someSpriteMadeUp", but the rectangle of bitmapCache is like a mask, covering every thing behind it, even the transparent part and out of the boundary of container.hitArea.

Then I tried:

var container:Sprite = new Sprite();

var bitmapCantainer:Sprite = new Sprite();

bitmapCantainer.addChild(bitmapCache);

bitmapCantainer.mouseEnabled = false;

bitmapCantainer.mouseChildren = false;

container.addChild(bitmapCantainer);

container.hitArea = someSpriteMadeUp;

Nothing changed, just like the first way.

So my question is, is there any way I can prevent bitmap's transparent part covering display objects behind? just like normal sprites do.

Thank you for any suggestion!

All best

Andrew.

This topic has been closed for replies.

1 reply

AndrewYuCWA1987
Known Participant
December 20, 2011

I think I've figure out what is happening here. Previous post didn't descript the situation quite clear, it is acturally like this:

// previous code:

var container:Sprite = new Sprite();
var bitmapCantainer:Sprite = new Sprite();

bitmapCantainer.addChild(bitmapCache);
bitmapCantainer.mouseEnabled = false;
bitmapCantainer.mouseChildren = false;

container.addChild(bitmapCantainer);
container.hitArea = someSpriteMadeUp;


// -------------------------------

// it turns out there'is a parent container of the "container" sprite I created

// and I disable that

parentContainer.mouseEnabled = false;


So now I don't need to avoid any interaction of transparent part of bitmap with mouse evnets, JUST set mouseEnabled property to false of the parent display object which is in the same depth of display list of which those display objects you don't what be "covered" are in.