How can I make Flex dispatch mouse events only when I interact with visible parts of a component? In this case I want event to be dispatched only when hovering the line.
<s:Group mouseOver="trace('over')">
<s:Line xFrom="0" yFrom="0" xTo="100" yTo="100">
<s:stroke>
<s:SolidColorStroke color="0" weight="3"/>
</s:stroke>
</s:Line>
</s:Group>
I remember I had a problem some time ago in Flex 3, when I couldn't catch mouse events until I fill the canvas with transparent background. But now I have the opposite problem. Thanks for help.
You're on the right track.
As you've already done, you need to wrap the
Lineobject in aGroup, or some other container class, because the Spark graphics primitives (likeLine) do not dispatch mouse events.I assume your problem is that since your line is diagonal, the bounding box for the
Groupis a rectangle that is much larger than the line.If you draw a horizontal or vertical line, the bounding box of the
Groupshould then just be the dimensions of theLine. Then rotate theGroupto get your diagonal line:Note, I've just picked a random X value, and rotation ... The rotation has the effect of displacing the object's X/Y coordinates ... unless your using something other than the
BasicLayout. So you'll have to adjust x/y/rotation (and/or the layout) to position your line at the right spot.