I'm using 2.0, I'm not in a huge hurry to upgrade right before I finish this
project :)
Thank you for offering help, I got it working by changing the TileList
attribute dragMoveEnabled="true" (I didn't realize this could be turned on
when using custom drag and drop handling).
On 1/10/07, Paolo Bernardini <[EMAIL PROTECTED]> wrote:
are you using flex 2.0 or 2.0.1?
I have an application using drag and drop and need to move the items
within the TileList, it was working just fine in version 2.0, now since I
updated to 2.0.1 it doesn't move the items anymore but instead makes a
copy.
Basically I want to order the Items of the TileList by dragging them, but
I also want to drag items from a different component. As I said it worked
with flex 2.0.
Here is the code:
<?xml version="1.0" encoding="utf-8"?>
<mx:TileList
xmlns:mx="http://www.adobe.com/2006/mxml"
backgroundAlpha=" 0" backgroundColor="#FFFFFF"
itemRenderer=" renderer.ProjectThumbnail"
dragEnabled="true"
dragEnter="doDragEnter(event)"
dragExit="doDragExit(event)"
dragDrop="doDragDrop(event)"
dragOver="doDragOver(event)"
mouseDown="dropInitiator = DragManager.MOVE;"
dragMoveEnabled="true ">
<mx:Script>
<![CDATA[
*import* mx.collections.IList;
*import* mx.collections.ArrayCollection ;
*import* events.CompareImageChangeEvent;
*import* mx.events.DragEvent;
* import* mx.managers.DragManager;
*import* mx.core.DragSource;
* import* com.cnh.imageBank.model.ModelLocator;
[
*Bindable*] *public* *var * model:ModelLocator = ModelLocator.getInstance
();
*private* *var* dropInitiator:String = DragManager.NONE;
*// Drag and drop events
**public* *function * doDragEnter(event:DragEvent): *void* {
*// Get the drop target component from the event object.
**var* dropTarget:TileList = event.currentTarget *as* TileList;
* var* dataInfo:ArrayCollection = dropTarget.dataProvider *as*ArrayCollection;
*var * item:Object = event.dragSource.dataForFormat(*"item"*);
*if* (dropInitiator == DragManager.MOVE){
DragManager.showFeedback(DragManager.MOVE);
DragManager.acceptDragDrop(dropTarget);
} *else* {
* if*(item != *null*){
*for*(* var* i:int = 0; i < dataInfo.length; i++){
*if*(dataInfo[i].id == item.id) * return*;
}
DragManager.showFeedback(DragManager.COPY);
DragManager.acceptDragDrop(dropTarget);
}
}
}*
** public* *function* doDragExit(event: DragEvent): *void* {
*var* dropTarget:TileList = event.currentTarget *as* TileList;
dropTarget.hideDropFeedback(event);
dropInitiator = DragManager.NONE;
*this*.dropEnabled = *false*;
}
*public* *function* doDragOver(event: DragEvent): * void* {
*var* dropTarget:TileList = event.currentTarget *as* TileList;
dropTarget.showDropFeedback(event);
}
*
**public* * function* doDragDrop(event: DragEvent): *void* {
*var* dropTarget:TileList = event.currentTarget *as* TileList;
*var* item:Object = event.dragSource.dataForFormat( *"item"*);
*if* (item == *null* ) {
*// Item was dragged from the thumbnail view
**var* items:Object = event.dragSource.dataForFormat( *"items"*);
item = items[0];
}
*var* dropLoc:int = dropTarget.calculateDropIndex (event);
IList(dropTarget.dataProvider).addItemAt(item, dropLoc );**
doDragExit(event);
}
]]>
</mx:Script>
</mx:TileList>