I am wondering about the feasibility of creating a single 'Recycle Bin' button that could be placed in the header area and it would clear absolutely all graphics or selected items with a single click on its icon in the header bar.
I am wondering about the feasibility of creating a single 'Recycle Bin' button that could be placed in the header area and it would clear absolutely all graphics or selected items with a single click on its icon in the header bar.
Thanks!
This is quite easy.. Here are the steps and code needed (replace this.map with your map component)
- Loop thought all the map layers and find the all the graphics layers (code below)
[php]
/** * Get all the graphics layers inside the map */ public function GetAllGraphicLayers():ArrayCollection { var graphicsLayers:ArrayCollection = new ArrayCollection(); for each(var layer:Layer in this.map.layers) { if (layer is GraphicsLayer) { graphicsLayers.addItem(layer); } } return graphicsLayers; }
[/php]
Then loop through all the graphic layers and clear.. [php] public function ClearAll():void { var graphicLayers:ArrayCollection = GetAllGraphicLayers(); for each(var grapicsLayer:GraphicsLayer in graphicLayers) { grapicsLayer.clear(); } } [/php]
You could combine all the code i guess but i have it broken out for other reasons.