In my thread How to dynamically change the order of basemaps
http://forums.arcgis.com/threads/815...p-in-MapSwitch, Robert hinted me to use drag and drop properties. I borrowed a source code in
http://ghalex.com/blog/examples/CustomDrag/srcview/, and did the following customization as below:
1) In the <s:List> </s:List> block, added:
dragEnabled="true"
dragMoveEnabled="true"
dropEnabled="true"
dragOver="listDragOverHandler(event)"
2) In the <fx:script> </fs:script> body, added
import mx.managers.DragManager;
import mx.events.DragEvent;
private function listDragOverHandler( event:DragEvent ):void {
// with this call we are telling that we will handle the drag
event.preventDefault();
var selectedItem :XML = XML(basemapGallery.selectedItem);
var move :Number = Number(selectedItem.attribute('canMove'));
if (event.dragSource.hasFormat("items") && move) {
// Drag allowed
event.currentTarget.showDropFeedback(event);
DragManager.showFeedback(DragManager.MOVE);
return;
}
// Drag not allowed.
event.currentTarget.hideDropFeedback(event);
DragManager.showFeedback(DragManager.NONE);
}
Results: An error message is thrown:
ReferenceError: Error #1069: Property hideDropFeedback not found on spark.components.List and there is no default value.
at widgets.eMapSwitcher::eMapSwitcherWidget/listDragOverHandler()[C:\...\Flex Projec
at widgets.eMapSwitcher::eMapSwitcherWidget/__basemapGallery_dragOver()[C:\...\Flexviewer\Flexviewer\src\widgets\eMapSwitcher\eMapSwitcherWidget.mxml:616]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::UIComponent/dispatchEvent()
at mx.managers.dragClasses::DragProxy/_dispatchDragEvent()
at mx.managers.dragClasses::DragProxy/dispatchDragEvent()
at mx.managers.dragClasses::DragProxy/mouseMoveHandler()
After clicking the Continue button, the item does change its order.
In the source code, the original author used mx but in the eMapSwitch, it gets conflict with spark. How can this be debugged? Welcome your smart solution.