AnsweredAssumed Answered

Flex - removing graphics layer

Question asked by branch72 on Oct 6, 2014
Latest reply on Oct 8, 2014 by branch72

I hope there is an easy answer to this that my lack of programming skills is just not seeing.

 

I've modified the default 3.6 Flex Print tool to add a print area box like you can find in Tom Schuller's custom print script, 'PChPrintSOE'.  I've been able to get everything to work - the print area responds to changes in the layout and scale and when you hit print it only prints what is inside the box.  The only problem I'm having now is getting the print area to go away when you close the widget. 

 

I thought this would be simple but the WidgetTemplate that has the 'closed' event is in a different mxml from where the GraphicsLayer is declared and manipulated.  I just need 'hostBaseWidget.map.removeLayer(printGraphicsLayer);' to run when the 'wTemplate' in 'PrintWidget.mxml' is closed.  But the 'printGraphicsLayer' GraphicsLayer is in ExportWebMapForm.mxml.

 

I've tried adding an eventListener into 'ExportWebMapForm.mxml' but it either takes the graphic away at the wrong time or not at all.  I've tried declaring the GraphicsLayer in 'PrintWidget.mxml' and passing it to 'ExportWebMapForm.mxml' but haven't got that to work. 

 

I don't consider myself a flex programmer so I'm hoping I'm missing something really obvious.  Tom's original script contains the WidgetTemplate and GraphicsLayer all in the same .mxml so he just set the 'closed' parameter on the WidgetTemplate to run a function to remove the GraphicsLayer - I just don't know how to do this when the WidgetTemplate and GraphicsLayer are in 2 different .mxml's.

 

Here is a link to the site with the modified print tool: ArcGIS Viewer for Flex

 

Thanks for any help,

Jim

Outcomes