Select to view content in your preferred language

Move Picture Marker using Edit Tool

783
3
07-24-2010 07:33 AM
roufbaba
Deactivated User
I was trying to move Picture Maker using edit tool but when i activate it on mouse click event. I didnot get the target as graphic rather i get it as "CustomSprite". How can I move a picture graphic.
Here is what i was trying to do

private function activateEditTool(event:MouseEvent):void
   {
    if (event.target is Graphic)
    {
     myEditTool.activate(EditTool.MOVE, [ Graphic(event.target)]);
    }
   }


   protected function myGraphicsLayer_graphicAddHandler(event:GraphicEvent):void
   {
    event.graphic.addEventListener(MouseEvent.CLICK, activateEditTool);
   }





Thanks and Best Regards
Rouf
Tags (2)
0 Kudos
3 Replies
SarthakDatt
Frequent Contributor
Hey Rouf,

Every 'Event' object has a target and a currentTarget property that help you to keep track of where it is in the process of propagation. The target property refers to the dispatcher of the event. The currentTarget property refers to the current node that is being examined for event listeners.

In case of the SimpleMarkerSymbol the target is Graphic and you are fine, but in case of the PictureMarkerSymbol it�??s the CustomSprite which is added as a child of Graphic.

You can solve this using any one of the following:

a)  In your activateEditTool(), check event.currentTarget, that would be graphic in your case.
b)  In your activateEditTool(), check something like: if(event.target is Graphic || event.target.parent is Graphic)
c) Turn mouseChildren property on Graphic to false(doing that makes sure that your target is always the graphic)

To learn more about events and event propagation, you can look at : http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7cdb.html

Hope that helps.

-- Sarthak Datt
ESRI Flex Team
0 Kudos
roufbaba
Deactivated User
Hi Sarthak

Thankyou. I appreciate you support and illustration. I was successful in moving the marker


Thanks and Best Regards
Rouf
0 Kudos
Roman_Net_Follower
Emerging Contributor
Hello!
In my project I've implemented the drag'n'drop functionality for graphic object based on PictureMarkerSymbol using ArcGIS JavaScript API. Probably it will be useful for somebody. It's shown in my blog here - http://dotnetfollower.com/wordpress/2011/07/arcgis-javascript-api-how-to-implement-dragndropping-of-...
Thanks!
0 Kudos