Flex: Troubleshooting mouse event issues.
Friday, July 11th, 2008Posted by Susie Sullivan, Developer, Thru-u.com.
If mouse events do not fire as you expect here are some things to consider.
1. mouseOver/mouseOut vs rollOver/rollOut:If, for example, you create a custom button out of other components, mouseOver and mouseOut can have undesirable results. Often rollOver/rollOut is more suitable. mouseOver/mouseOut will record mouse events for each internal component, whereas rollOver/rollOut will just return events for the main component.
Setting:
mouseChildren = false
will have the same effect when used with mouseOver/mouseOut.
2. Transparencies:
A canvas with no background will fire a rollout/mouseout event when you roll off child components. If the whole canvas is to be the source of the event, the background will need to be present, with alpha of 0 if necessary.
3. Depth of component:If rollover or click events are not being registered especially for parts of a canvas, consider whether a transparent canvas was added after the mouse effect object. To bring any component (in this case canv) to the front, call the following after the UI has been built:
canv.parent.setChildIndex(canv, Canvas(canv.parent).getChildren().length-1)