Select to view content in your preferred language

map click event listener on latest flex api

2469
3
02-25-2013 04:48 PM
AndrewThomas
Deactivated User
I have a flex application I am migrating from API 2.4/Flex SDK4.5 to API 3.1 (December 2012 release)/Flex SDK4.6.

The application has an editing of feature layers without using the editor.

I have a feature layer with a click event listener.
This feature layer click event handler shows an info window and adds a map click event listener to the map.
The map click event clears the layer selection and hides the info window.

In other words, user clicks on a feature and a pop up appears. If the user clicks anywhere on the map, the feature is deselected and the popup hides.

After the migration however, the map click event handler is called even though the listener is added by the feature click event handler. It seems like it's remembering the map click event (when the user clicked on the feature) and when the map click event listener is added to the map, the map click handler is called from an event that occurred before it started listening (an echo perhaps?).

Don't believe me?

Try this (it only takes a few minutes):

In Flash builder:

  • Create a new project using the 4.6 SDK

  • Add an SWC reference to the 12/12/12 ArcGIS for flex API library in the project properties (Flex Build path)

  • In the default mxml file, copy and paste the contents from the edit without editor sample below

  • Run the mxml (in debug mode preferably)


In the Browser:
If no polygon exists:

  • Create a polygon

  • Click the 'select features by rectangle'

  • Click on the rectangle to change the tool.

  • Click 'Clear Selection'


When a polygon exists:

  • Click in the feature and try and change the vertex points.


They disappear a split second after the feature is clicked which is different behaviour to the on-line example.


  • Add a break point on the map click event handler to show that this is in fact being called when the feature is clicked.


However, presumably the samples are using the latest 12/12/12 API release (from what I can tell from the swf file modification date), which means there is something with my environment which is causing this problem???? I would appreciate someone else trying to replicate this problem.

On-line Example/Sample:
http://resources.arcgis.com/en/help/flex-api/samples/index.html#/Edit_without_Editor/01nq00000043000...

Latest ArcGIS flex API (12/12/12 at the time of post)
http://www.esri.com/apps/products/download/index.cfm?fuseaction=download.main&downloadid=849

I did notice the layer click handler method had a remove listener function right before it's added again. I don't know if that was a vain attempt to try and 'forget' existing map click events?

Regards

Andrew
Tags (2)
0 Kudos
3 Replies
IvanBespalov
Frequent Contributor
Sample page has notice
All the Flex API samples are also included in the Flex API Library download.


So try to run sample with same name from downloaded api (not from web help), its code has some differences with it's web version. This sample works.
In this sample (in API) map listener is added once and never removed.

Good luck.

P.S. map click event listener works fine when placed in right place and added in right moment
0 Kudos
AndrewThomas
Deactivated User
Thanks Ivan.

Yes, the new download does work and I managed to change my code to work around the issues.
I didn't really get to the bottom of it though.



P.S. map click event listener works fine when placed in right place and added in right moment


I still think something has changed though. Perhaps it wasn't in the right place and wasn't added at the right moment in the previous version but it worked anyway.... and now it does not.

I have come across a few undocumented changes  - or at least I haven't found the documentation despite my best efforts.
0 Kudos
stevemclaughlin
Occasional Contributor
Older versions of the API used to have an automovetotop function that could be used to automatically move the graphic to the top of the stack on mouse over, but this seems to have been depreciated in 3.1:

could this have caused your problems?
0 Kudos