invertedSpear
invertedSpear

Reputation: 11054

Make an MXML component report the target of the click as the component and not the children

So, I have a component based on canvas, and within that component I have two images. I have the component listen for a click and when that event occurs one image goes transparent and the other becomes visible.

This part works perfect.

Now, on clicking that component, I also want to do something to the parent canvas, I already have this working for more basic types (image, canvas, text, etc) but the problem with my component is that the click event has the internal image as the target, so what I want to happen to the outside canvas is happening to the canvas of the component.

How do I make my component as a whole the target of any clicks on it?

3.5 SDK

Upvotes: 3

Views: 231

Answers (2)

invertedSpear
invertedSpear

Reputation: 11054

I handled this by adding a click handler to the children that would stop immediate propagation, then dispatch a click event from the outer component. Wade's solution is much better.

Upvotes: 0

Wade Mueller
Wade Mueller

Reputation: 6059

You can make the outer component the target of the clicks by setting mouseChildren = false on the outer component. Clicking anywhere within the component (including on any of the sub-components) will then set the event target to the outer component. Hope that helps.

Upvotes: 4

Related Questions