Это не очевидно, пока вы не попробовали это =) Я боролся с тем же самым делом всего несколько недель назад. Это было мое решение:
Список:
<List>
<mouseDown>onListMouseDown(event)</mouseDown>
</Tree>
мышь вниз обработчик:
private function onMouseDown(event : MouseEvent) : void {
var list : List = List(event.currentTarget);
// the data of the clicked row, change the name of the class to your own
var item : MyDataType = MyDataType(list.selectedItem);
var source : DragSource = new DragSource();
// MyAwsomeDragFormat is the key that you will retrieve the data by in the
// component that handles the drop
source.addData(item, "MyAwsomeDragFormat");
// this is the component that will be shown as the drag proxy image
var dragView : UIComponent = new Image();
// set the source of the image to a bigger version here
dragView.source = getABiggerImage(item);
// get hold of the renderer of the clicked row, to use as the drag initiator
var rowRenderer : UIComponent = UIComponent(list.indexToItemRenderer(list.selectedIndex));
DragManager.doDrag(
rowRenderer,
source,
event,
dragView
);
}
Это будет начать перетаскивание, когда пользователь нажимает на элемент в списке. Обратите внимание, что я не устанавливаю dragEnabled
и другие свойства, связанные с перетаскиванием, поскольку я сам все это обрабатываю.
Это может быть полезно, чтобы добавить это начало обработчика событий:
if (event.target is ScrollThumb || event.target is Button) {
return;
}
Просто к короткому замыканию, если пользователь щелкает где-то в скроллинга. Это не очень элегантно, но это делает работу.
dragView должен устанавливать ширину и высоту :) – jason 2013-03-25 08:36:50