Macromedia flex 2-migrating applications to flex 2 User Manual
Using the drag-and-drop feature
181
Controlling the feedback indicator
To control the feedback indicator that accompanies a drag proxy, you now use the new
showFeedback()
and
getFeedback()
methods of the DragManager class. The indicator
shows what happens if you try to drop the item; for example, a red circle with a white x
represents an aborted drop, or a green circle with a white plus (+) indicates a valid drop.
represents an aborted drop, or a green circle with a white plus (+) indicates a valid drop.
In Flex 1.x, you could change the feedback indicator with the
action
property of the event.
In Flex 2, use the
showFeedback()
method to control the value of this property for all
DragManager-related events. To get this value on any DragEvent object, you now use the
getFeedback()
method.
Setting actions
You no longer set the
action
property of the event object. Instead, you must call the
DragManager.setFeedback()
method, as the following example shows.
Flex 1.5:
private function doDragOver(event:Event):Void {
// If the Control key is down, show the COPY drag feedback appearance.
if (event.ctrlKey) {
if (event.ctrlKey) {
event.action = DragManager.COPY;
} else {
event.action = DragManager.MOVE;
}
}
Flex 2:
private function doDragOver(event:DragEvent):void {
// If the Control key is down, show the COPY drag feedback appearance.
if (event.ctrlKey) {
if (event.ctrlKey) {
DragManager.showFeedback(DragManager.COPY);
} else {
DragManager.showFeedback(DragManager.MOVE);
}
}