Hi all,
I have a tree component with an xml file as dataprovider.
I would like to move node from one parent to other one, previously an alert
message.
1.- I drag a node
2.- Before drop this node in new parent node, i want to display an alert
message.
3.- If the user click YES, i want to move the node to the new parent
4.- If the user click NO, i want to cancel the drag and drop event.
Here is my source:
in the tree component i have the next properties:
dropEnabled="true"
dragEnabled="true"
dragMoveEnabled="true"
dragDrop="customDragDrop(event)"
allowMultipleSelection="false"
The customDragDrop(event) function is:
import mx.events.DragEvent;
import mx.managers.DragManager;
private var queuedEvent:DragEvent;
private function customDragDrop(event:DragEvent): void
{
//Get the data from the dragSource
var items:Object = event.dragSource.dataForFormat("treeItems");
event.stopPropagation();
queuedEvent = event as DragEvent;
var messageText:String = "Are you sure you want to move the node "
+ items[[email protected]() + "?";
var titleText:String = "Warning";
var alert:Alert = Alert.show(messageText, titleText,
Alert.NO | Alert.YES,
this, customDragDropHandler,alertIcon);
}
private function customDragDropHandler(event:CloseEvent):void{
if (event.detail == Alert.NO){
queuedEvent.preventDefault();
queuedEvent.target.hideDropFeedback(queuedEvent);
DragManager.showFeedback(DragManager.NONE);
}
else {
dispatchEvent(queuedEvent);
}
}
I don“t know why i can not get my solution, please i need your help.
Thanks in advance.