我有一个组,其中有许多不同的图形基元。如果我单击该组,我可以在 MouseEvent(event).currentTarget 中获得对它的引用。但是我怎么知道我是否点击了一个图形基元?
示例代码:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
protected function group1_mouseDownHandler(event:MouseEvent):void {
trace("event target="+ event.target);
// traces the group
}
]]>
</fx:Script>
<s:Group width="500" height="500" horizontalCenter="0" verticalCenter="0"
mouseDown="group1_mouseDownHandler(event)"
mouseEnabledWhereTransparent="true">
<s:Rect x="10" width="100" height="100" radiusX="10" radiusY="10">
<s:fill>
<s:SolidColor color="#ff0000"/>
</s:fill>
</s:Rect>
<s:Ellipse x="150" width="100" height="100">
<s:fill>
<s:SolidColor color="#ff0000"/>
</s:fill>
</s:Ellipse>
</s:Group>
</s:Application>