apache-flexfxg

How to determine which path element clicked in FXG file


I am working on a sample map application using Flex 4/fxg? Now I have got FXG paths held in Group elements with id's( I have assigned path's id's to the corresponding group container)? But when I click anywhere in the map, I do not get the clicked group as target/currentTarget in event handler. How to determine which element is clicked?

Code sample:

<Graphic xmlns:fx="http://ns.adobe.com/mxml/2009" 
         xmlns="library://ns.adobe.com/flex/spark" 
         xmlns:mx="library://ns.adobe.com/flex/mx" 
         xmlns:view="view.*"
         version="2.0" viewWidth="1425" viewHeight="1140">
----
----

            <view:GraphicItem id="CityofLondon">
                <Path data="path data" winding="evenOdd">
                    <fill>
                        <SolidColor color="#FEFEE9" alpha="1"/>
                    </fill>
                    <stroke>
                        <SolidColorStroke color="#646464" alpha="1" weight="2" miterLimit="10" joints="round" caps="round"/>
                    </stroke>
                </Path>
            </view:GraphicItem>
            <view:GraphicItem id="BarkingandDagenham">
                <Path data="path data" winding="evenOdd">
                    <fill>
                        <SolidColor color="#FEFEE9" alpha="1"/>
                    </fill>
                    <stroke>
                        <SolidColorStroke color="#646464" alpha="1" weight="2" miterLimit="10" joints="round" caps="round"/>
                    </stroke>
                </Path>
            </view:GraphicItem>
----
------
</Graphic>

GraphicItem is Group container.

Any help would be greatly appreciated. Thanks.


Solution

  • I asked a similar question, and it is answered here:

    Flex Path - capturing Click event

    Had to set the mouseEnabledWhereTransparent="false" to a Group, and add the FXG path to that group.