I have a panel component on my flex application. This component has a click event which is fired when the used makes click on the panel. But I would like to know the zone of the panel where click was made. In fact what I want to know is if click was made on the title bar of the panel. How can I do that?
+3
A:
The MouseEvent stores the location of the mouse when the click was made in the localX
and localY
properties. That way you can calculate a bit to find out, if the mouse was above the title bar or not.
function panelClick ( event:MouseEvent ) : void
{
trace( event.localX + '/' + event.localY );
}
Most standard components also offer access to some of their child elements. The Panel component for example has a property Panel.titleBar that can be accessed when deriving a new component class. So you could for example create a new class that offers a special event for clicks on the title bar, by making it possible to add an event listener for the title bar from the outside.
poke
2009-12-19 15:09:13
Thank you! Finally I created a custom component extending Panel class and added a function that returns the titleBar property to get its width and height.
Kezern
2009-12-20 20:33:22